Unable to decrypt all files

Nextcloud version (eg, 20.0.5): 22.2.0
Operating system and version (eg, Ubuntu 20.04): Ubuntu 18.04.5

The issue you are facing:

I am unable to run occ encryption:decrypt-all It fails with the following error:

TypeError: fclose(): Argument #1 ($stream) must be of type resource, string given in /data-directory/htdocs/lib/private/Files/Storage/Wrapper/Encryption.php:759
Stack trace:
#0 /data-directory/htdocs/lib/private/Files/Storage/Wrapper/Encryption.php(759): fclose()
#1 /data-directory/htdocs/lib/private/Files/Storage/Wrapper/Encryption.php(651): OC\Files\Storage\Wrapper\Encryption->copyBetweenStorage()
#2 /data-directory/htdocs/lib/private/Files/Storage/Wrapper/Encryption.php(361): OC\Files\Storage\Wrapper\Encryption->copyFromStorage()
#3 /data-directory/htdocs/lib/private/Files/View.php(935): OC\Files\Storage\Wrapper\Encryption->copy()
#4 /data-directory/htdocs/lib/private/Encryption/DecryptAll.php(264): OC\Files\View->copy()
#5 /data-directory/htdocs/lib/private/Encryption/DecryptAll.php(229): OC\Encryption\DecryptAll->decryptFile()
#6 /data-directory/htdocs/lib/private/Encryption/DecryptAll.php(188): OC\Encryption\DecryptAll->decryptUsersFiles()
#7 /data-directory/htdocs/lib/private/Encryption/DecryptAll.php(99): OC\Encryption\DecryptAll->decryptAllUsersFiles()
#8 /data-directory/htdocs/core/Command/Encryption/DecryptAll.php(173): OC\Encryption\DecryptAll->decryptAll()
#9 /data-directory/htdocs/3rdparty/symfony/console/Command/Command.php(255): OC\Core\Command\Encryption\DecryptAll->execute()
#10 /data-directory/htdocs/3rdparty/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run()
#11 /data-directory/htdocs/3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
#12 /data-directory/htdocs/3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#13 /data-directory/htdocs/lib/private/Console/Application.php(209): Symfony\Component\Console\Application->run()
#14 /data-directory/htdocs/console.php(99): OC\Console\Application->run()
#15 /data-directory/htdocs/occ(11): require_once('...')
#16 {main}

This is external storage located in Amazon S3. I have been unable to download files from S3 that have been encrypted by NextCloud.

Legacy v2 authentication is turned off on the S3 bucket, but this still occurs.

1 Like

I am having the exact same error when decrypting files stored in a mounted SSD. The error is thrown half-way through decryption. I am able to manually turn off the maintenance mode and access my files, but the decryption is obviously not done.

I am using Ubuntu 20.10 and Nextcloud 22.2.3

1 Like

@caony

Did you manage to progress any further?

I’m trying this, but I’m working with huge volumes of data and it’s slow GitHub - syseleven/nextcloud-tools: This project contains tools to operate Nextcloud.

So after some tinkering, I found out that the issue is caused by having encrypted and unencrypted data coexisting. The latter was uploaded via rsync. Weird that the file scan doesn’t encrypt them, but they are accessible in disk anyhow.

Now I am slightly stuck–I can neither fully encrypt them all or decrypt them, although I have a full backup via rclone. rclone works ok-ish syncing with the server–hash checking etc, just not downloading the unencrypted files.

I am thinking about re-uploading all the files (I only have 100+G). I hope the tool could help you.
@devhops

@caony

This is the same situation I’m in, the data I can access was manually moved to the S3 bucket from an old SFTP server. The new data that’s been uploaded to nextcloud since is inaccessible.

I’m not in a position to reupload the files, but if I were you, I would certainly try it. I did make a test instance from a clone, just in case.