[SOLVED] Can't delete permanently: "Permission denied"

I’m having an issue deleting files in the web interface. This looks like a permission problem: could somebody help me?

Steps to reproduce

  1. Delete a folder (1.7 GB in my case)
  2. Go to trashbin
  3. Delete the folder from trash

Expected behaviour

Folder is permanently deleted

Actual behaviour

Error message: “Can’t delete permanently”


Error | trashbin | can't delete /Alice.d1504790954/Alice-Backup//IMG_20151210_161610.jpg permanently. | 2017-09-07T15:43:45+0200
-- | -- | -- | --
Error | PHP | unlink(/media/raid/ncdata/data/etienne/files_trashbin/files/Alice.d1504790954/Alice-Backup/IMG_20151210_161610.jpg):  Permission denied at  /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#220 | 2017-09-07T15:43:45+0200

For information:

  • /media/raid/ncdata/data is my nextcloud data folder, outside of /var/www/html/nextcloud/. www-data has ownership over this folder
  • I had added this folder in the data folder manually, and performed a rescan (occ files:scan). It worked perfectly and I could see the folder in my web interface without issue.
  • I was able to delete some files in a sub-folder “Boston” of this folder. But not able to delete “Boston” itself

Server configuration

Debian GNU/Linux 9.1 (stretch)
Server version: Apache/2.4.25 (Debian)
Server built:   2017-07-18T18:37:33
PHP 7.0.19-1 (cli) (built: May 11 2017 14:04:47) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.19-1, Copyright (c) 1999-2017, by Zend Technologies
mariadb  Ver 15.1 Distrib 10.1.26-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Nextcloud version 12.0.2
  - installed: true
  - version:
  - versionstring: 12.0.2

Can you verify the permissions for this file?

thank you @tflidd
Permissions are www-data:www-data with -r--------
So I can understand why Nextcloud cannot delete it. What I can’t understand, is that other files, with same permissions, have been permanently deleted, in a subfolder of this folder.

Then I tried to change the permissions: chmod +w IMG_20151210_161610.jpg
Permissions are now -rw------- 1 www-data www-data
But Nextcloud cannot delete it either. And idem with -rw-rw-rw-

Do you understand?

Would anybody have an idea about this issue?

What kind of system do you have? If you put files via webinterface, it is strange that php puts something as read-only …

Hello, in fact, it wasn’t added on the web interface:

I also tried the following:

sudo -u www-data php occ files:scan --path="/etienne/files_trashbin/files"

But still impossible to delete

Solution found: the problem came from the parent directory, which had only r permissions. I added w permissions, and it worked.
Thank you for your help.