Restored files from trash are empty

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:

example

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

longer
example
here

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, 20.0.5): 21.0.2
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04.2 LTS
Apache or nginx version (eg, Apache 2.4.25): 2.4.38
PHP version (eg, 7.4): 7.4
(Using docker image nextcloud:21.0.2)

The issue you are facing:
I can delete and restore files from trash, but after restoring file, file is empty.
More complicated files than text files (xlsx, pdf) are corrupt afterwards.
Nevertheless, moving files works properly (this info refers to second log).

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

Steps to replicate it:

  1. Create md file and write some words
  2. Delete md file
  3. Restore md file from trash bin
  4. Open md file
  5. File is empty

The output of your Nextcloud log in Admin > Logging:

[files_trashbin] Error: trash bin database inconsistent! ($user: cloudadmin $filename: hello.md.md, $timestamp: 1623841739)

MOVE /remote.php/dav/trashbin/cloudadmin/trash/hello.md.md.d1623841739
from 77.191.110.99 by cloudadmin at 2021-06-16T11:09:04+00:00

and before (this is propably the reason):

[no app in context] Info: Can't move file files/hello.md.md to the trash bin, therefore it was deleted right away

DELETE /remote.php/dav/files/cloudadmin/hello.md.md
from 77.191.110.99 by cloudadmin at 2021-06-16T11:08:59+00:00

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => 'xxx',
    1 => 'xxx',
  ),
  'datadirectory' => '/var/www/html/data',
  'overwrite.cli.url' => 'xxx',
  'overwriteprotocol' => 'https',
  'dbtype' => 'pgsql',
  'version' => '21.0.2.1',
  'dbname' => 'nextcloud',
  'dbhost' => 'nextcloud_oo_db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'xxx',
  'dbpassword' => 'xxx',
  'installed' => true,
  'loglevel' => 0,
  'maintenance' => false,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'service',
  'mail_domain' => 'xxx',
  'mail_smtphost' => 'xxx',
  'mail_smtpport' => 'xxx',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'xxx',
  'mail_smtppassword' => 'xxx',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauthtype' => 'LOGIN',
  'simpleSignUpLink.shown' => false,
  'encryption.legacy_format_support' => true,
  'encryption.key_storage_migrated' => false,
  'theme' => '',
);

good point - this looks like the root cause…

as first step I would try to run occ files:cleanup and files:scan commands… they are expected to fix files<>DB inconstency… then try if works again.

Thanks for the advice, but I already did files:scan before. Now, I also did files:cleanup (which removed 1 orphan file only), but bug still exists.

FYI In the log, I also see many of those Deprecated infos (this is an example - it occurs for many different events - not only preview):

[no app in context] Info: Deprecated event type for OCP\IPreview:PreviewRequested: Symfony\Component\EventDispatcher\GenericEvent is used

GET /core/preview?fileId=851394&x=32&y=32
from 89.12.84.1 by cloudadmin at 2021-06-17T06:42:55+00:00

But this should be unrelated, as I read here, right?