Difficulty deleting a file

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:


Or for longer, use three backticks above and below the code snippet:


Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 12.0.2): 15.0.7
Operating system and version (eg, Ubuntu 17.04): Raspbian GNU/Linux 9 (stretch)
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.25 (Raspbian)
PHP version (eg, 7.1): PHP 7.0.33-0+deb9u3

The issue you are facing:

I found my cat sleeping on my laptop this morning. Big mistake.
The bugger, among other things, managed to rename a file on my desktop to

The desktop from my macbookpro laptop is synched to a folder in my nextcloud instance (using the nextcloud app 2.5.1final (build 20181204)).

Of course the app reported a synchronising error.

First thing i did was to erase the file from the desktop. That went well, but the nextcloud didn’t follow.

ssh’d into my raspberry, as root, manually deleted the file, then ran an occ files:scan to the desktop folder…

Surprise, file is still in the nextcloud directory, but neither on the nextcloud data drive, nor on my laptop desktop…

The file only appears in the nextcloud web interface, and can’t be deleted from there…

I now have no idea how to delete this non existant file from nextcloud…

Is this the first time you’ve seen this error? (Y/N): y

Steps to replicate it:

  1. Let cat sleep on nextcloud synched laptop
  2. Have a too long file name renamed file
  3. Delete the file

The output of your Nextcloud log in Admin > Logging:

Error	gallery	Exception: Preview generation has failed	
Error	gallery	OCP\Files\NotFoundException: 	
Error	metadata	Exception: Unsupported MIME type "".	
Fatal	webdav	Sabre\DAV\Exception\BadRequest: expected filesize 100000000 got 88252416	
Error	no app in context	Sabre\DAV\Exception\BadRequest: expected filesize 100000000 got 88252416	
Error	no app in context	OCP\Files\InvalidPathException: File name is too long	

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):


The output of your Apache/nginx/system log in /var/log/____:



A tough one. When nothing else worked and the file is already deleted on the filesystem, then you can only free relevant DB tables from this file entry.
The big question is then: which table or tables is it?

I believe the relevant table is [db_prefix]_filecache. At least the number of entries in this table match the number of “Files” in the admin settings under “Monitoring” - “Storage” for me.

So you could make a backup of your database and delete the entry for that file.

  1. Enable maintenance mode by running the occ command with maintenance:mode --on
  2. Backup the database! (https://docs.nextcloud.com/server/stable/admin_manual/maintenance/backup.html?#backup-database)
  3. connect to the database
  4. check the correct DB table prefix (maybe oc_) by running
    show tables;
  5. Search for the relavant file (I assume the db table prefix is oc_:
    select * from oc_filecache where name like 'p-----------%';
  6. if the query from step 5 doesn’t find the file, continue if you feel comfortable with moving in the DB or abort and report back here
  7. if the query from step 5 finds the file in question and there is only this one file returned(!), you can run the following query:
    delete from oc_filecache where name like 'p-----------%';
  8. disable maintenance mode by running occ command with maintenance:mode --off

When the DB entry is successfully deleted, perform a full refresh of your NC web page (CTRL + F5) and check if the file is still there.
Please let me know :slight_smile:

1 Like

Well, Schmu !!!
Thank you greatly for your help.
This solved the problem in no time !

I ran :

SELECT * FROM oc_filecache WHERE name LIKE ‘p-------%’

And of course found the relevant entry.

I deleted this line of the db, and VOILA ! The file has disapeared successfully, my synch app is back to green !

Many kind regards,

1 Like

I’m glad it worked that easy :slight_smile:

1 Like

Another simple way to cope with the pathes and long names is LongPathTool.
Very convenient and helpful. Google and try it. Download now - thank me later :slight_smile:

Thank you for the proposition.
How does this tool integrate and is relevant to a nextcloud instance ?