Cannot decrypt some files after moving to encrypted external storage and then back

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:

Files for following users couldn't be decrypted,
maybe the user is not set up in a way that supports this operation:
    basilgohar
        /basilgohar/files/BackblazeB2/2012-05-01, Alahfad/Alahfad 001.jpg
        /basilgohar/files/BackblazeB2/2012-05-01, Alahfad/Alahfad 002.jpg
        /basilgohar/files/BackblazeB2/2012-05-01, Alahfad/Readme.md
        /basilgohar/files/BackblazeB2/2012-05-01, Alahfad/Thumbs.db
        /basilgohar/files/video/145961.mp4
        /basilgohar/files/video/Facebook video #1049849491731037-1049849491731037.mp4
        /basilgohar/files/video/Masjid Omar Columbus OH - Timeline Facebook.mp4
        /basilgohar/files/video/VID-20150630-WA0002.mp4
        /basilgohar/files/video/sony_fdr-ax33/00003.MTS
        /basilgohar/files/video/sony_fdr-ax33/00004.MTS
        /basilgohar/files/video/sony_fdr-ax33/00010.MTS
        /basilgohar/files/video/sony_fdr-ax33/00011.MTS
        /basilgohar/files/video/sony_fdr-ax33/00012.MTS
        /basilgohar/files/video/sony_fdr-ax33/00013.MTS
        /basilgohar/files/video/sony_fdr-ax33/00014.MTS
        /basilgohar/files/video/sony_fdr-ax33/2018-03-17/00000.MTS
        /basilgohar/files/video/sony_fdr-ax33/2018-03-17/C0005.MP4
        /basilgohar/files/video/sony_fdr-ax33/2018-03-17/C0006.MP4
        /basilgohar/files/video/sony_fdr-ax33/2018-03-17/2/00000.MTS
        /basilgohar/files/video/sony_fdr-ax33/2018-03-17/2/C0002.MP4
        /basilgohar/files/video/sony_fdr-ax33/2018-03-17/2/C0002.MP4_rencoded.mp4
        /basilgohar/files/video/sony_fdr-ax33/2018-03-17/2/C0004.MP4

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, 18.0.2): 18.0.4.2
Operating system and version (eg, Ubuntu 20.04): CentOS 7
Apache or nginx version (eg, Apache 2.4.25): Apache HTTP Server 2.4.34
PHP version (eg, 7.1): 7.3.18

The issue you are facing:

Some files are listed as unable to be encrypted after I attempted to move them into encrypted External Storage (BackBlaze B2 via their new S3-compatible layer) and that failed. Files that were either moved back or never moved in the first place are inaccessible or cannot be moved to other external storage (e.g., SFTP) with no encryption with an error message that reads:

 Hint":"Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.

Is this the first time you’ve seen this error? (Y/N): Y, but I have had problems with encryption in the past the necessitated reinstalling Nextcloud entirely.

Steps to replicate it:

  1. Create an external storage.
  2. Attempt to move files with Nextcloud from normal/local storage to external storage with encryption on exteral storage enable.
  3. When some of those transfer fail, attempt to decrypt all files with sudo -u apache php /var/www/nextcloud/occ encryption:decrypt-all

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

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

<?php
$CONFIG = array (
  'debug' => true,
  'instanceid' => '*',
  'passwordsalt' => '*',
  'secret' => '*',
  'trusted_domains' => 
  array (
    0 => '*',
  ),
  'datadirectory' => '*',
  'overwrite.cli.url' => '*',
  'dbtype' => 'mysql',
  'version' => '18.0.4.2',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '*',
  'dbpassword' => '*',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'updater.release.channel' => 'stable',
  'enable_previews' => true,
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\PNG',
    1 => 'OC\\Preview\\JPEG',
    2 => 'OC\\Preview\\GIF',
    3 => 'OC\\Preview\\BMP',
    4 => 'OC\\Preview\\HEIC',
    5 => 'OC\\Preview\\XBitmap',
    6 => 'OC\\Preview\\MarkDown',
    7 => 'OC\\Preview\\MP3',
    8 => 'OC\\Preview\\TXT',
    9 => 'OC\\Preview\\Movie',
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauth' => 1,
  'mail_smtphost' => '*',
  'mail_smtpport' => '587',
  'mail_smtpsecure' => 'tls',
  'mail_from_address' => '*',
  'mail_domain' => '*',
  'mail_smtpname' => '*',
  'mail_smtppassword' => '*',
);

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

[Tue Jun 02 05:46:27.332814 2020] [php7:error] [pid 27151] [client 24.192.122.20:52948] PHP Fatal error:  Uncaught PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction in /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117\nStack trace:\n#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(117): PDOStatement->execute(NULL)\n#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1054): Doctrine\\DBAL\\Driver\\PDOStatement->execute()\n#2 /var/www/nextcloud/lib/private/DB/Connection.php(220): Doctrine\\DBAL\\Connection->executeUpdate('UPDATE `oc_file...', Array, Array)\n#3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(203): OC\\DB\\Connection->executeUpdate('UPDATE `oc_file...', Array, Array)\n#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(215): Doctrine\\DBAL\\Query\\QueryBuilder->execute()\n#5 /var/www/nextcloud/lib/private/Lock/DBLockingProvider.php(316): OC\\DB\\QueryBuilder\\QueryBuilder->execute()\n#6 [internal  in /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php on line 34