[Solved] Cannot Empty Trash 18.07

Nextcloud version 18.07
Operating system Ubuntu 20.04)
:
nginx version _1.19.1
PHP version _ 7.4.8

The issue I am facing: I have tried to empty my trash bin via the web interface and after screen refresh the files are still there. I’ve also tried using occ commands but the files will not delete. General log is below.

Is this the first time you’ve seen this error? (Yes):

Steps to replicate it:

  1. Delete files via web interface.
  2. Refresh screen
  3. Files re-appear

Using the following command (sudo -u www-data php occ trashbin:cleanup Bart)

generates the log shown below. No files have been deleted.

The output of your Nextcloud log in Admin > Logging:

Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#120	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/32): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/32/.local): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/32/.local/share): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/32/.local/share/icons): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/32/.local/share/icons/locolor): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/32/.local/share/icons/locolor/32x32): Not a directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/32/.local/share/icons/locolor/16x16): Not a directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/40): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/40/.local): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/40/.local/share): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/40/.local/share/icons): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/40/.local/share/icons/locolor): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/40/.local/share/icons/locolor/32x32): Not a directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/40/.local/share/icons/locolor/16x16): Not a directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/current): Not a directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/46): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/46/.local): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/46/.local/share): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/46/.local/share/icons): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114	
2020-07-20T22:38:52+1000
Error	PHP	rmdir(/mnt/storage1/nc_data/Bart/files_trashbin/files/snap.d1590450461/wavebox/46/.local/share/icons/locolor): Directory not empty at /var/www/nextcloud/lib/private/Files/Storage/Local.php#114

I hope that someone can help me. Thanks.

After further research I found this post and I followed the directions of the user “Mdoering”:

And this solved my problem. Directions below:

Mdoering

2

May '19

Yes there is a way if you have access to the NC-Instance-Commandline

  • ssh to your nextcloud server
  • $ sudo su
  • $ cd /path-to-your-nexcloud-data-location/ (this could be in /var/www/data/ for example)
    (this needs root privileges…thats why I mentioned $ sudo su before)

There you should see the users that have logged in your Instance
Now you should remember with wich user you have deleted your 800GB of files.
Then:

  • $ cd /the-users-directory/ , that you have used for deleting those files.
  • in there should be a “files_trashbin”
    -There you go:
    $ cd files_trashbin/files/
    and
    $ ls
    That should show you the files’ name and a cryptic file ending like “Filename.txt.31asd12”
    There you can delete the files you want to delete or
    $ rm *
    will delete anything in the folder.

Important:
Nextcloud doesnt know yet that you made manual changes in that directory. Now it is important to do the following

$ cd /var/www/nextcloud
(or the path you used for your NC-Instance-Webserver)
$ sudo -u www-data php occ files:scan {USERNAME}
({USERNAME} hast to be replaced by the name of the user you used to delete the files in NC)

This process will take a while…after that everything should be clean and nextcloud knows that the files are deleted and they are not listed in Web-Trashbin (this can be used to undelete files for example).

EDIT:
WARNING, if you do it like that, all files in trashbin will be deleted forever!!! If you are not sure about deleting, please consider to make a backup of those files!!!

1 Like

But if your Nextcloud runs from a snap, you can’t just “cd /var/www/nextcloud”. What do you do if you run nextcloud from a snap?

The data dir is here:
/var/snap/nextcloud/common/nextcloud/data/

I did a “nextcloud.occ list”, searching for anything to do with cleanup of user trash (and I don’t want to wait 30 days and trust the auto-expiry, I’d like to save the precious disk space on my VPS ASAP). Nothing of the sort.

Hi esbeeb, sorry I don’t have an answer for you as I have a conventional install not a snap install. My first install was from a Snap and I had some issues but there is very little information to help with a snap install as most will do a conventional install. As a result, instead of trying to find fixes I deleted my Snap install and started over doing a conventional install using an on line tutorial. That way if I have an issue there is normally easier to find a fix. Hope this helps.

1 Like

I’m coming around to that same conclusion: not to trust the snap any longer.

1 Like