diff --git a/apps/files/lib/Command/TransferOwnership.php b/apps/files/lib/Command/TransferOwnership.php index 50aa0b21a5f42..c14ab38cadbfd 100644 --- a/apps/files/lib/Command/TransferOwnership.php +++ b/apps/files/lib/Command/TransferOwnership.php @@ -96,7 +96,12 @@ protected function configure() { InputOption::VALUE_OPTIONAL, 'transfer incoming user file shares to destination user. Usage: --transfer-incoming-shares=1 (value required)', '2' - ); + )->addOption( + 'ignore-encryption-error', + null, + InputOption::VALUE_NONE, + 'ignore encryption error. Usage: --ignore-encryption-error', + ); } protected function execute(InputInterface $input, OutputInterface $output): int { @@ -146,6 +151,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int break; } + $GLOBALS['ignore-encryption-error'] = $input->getOption('ignore-encryption-error'); + $this->transferService->transfer( $sourceUserObject, $destinationUserObject, diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 3c65cdbc8f660..1df6bc5d8f8fe 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -758,7 +758,13 @@ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInte } catch (\Exception $e) { fclose($source); fclose($target); - throw $e; + $this->logger->logException(new \Exception("Fail to copy '$sourceInternalPath' to '$targetInternalPath'", 0, $e)); + if ($GLOBALS['ignore-encryption-error']) { + fwrite(STDERR, " - Skipping '$sourceInternalPath'" . $e->getMessage() . PHP_EOL); + $result = true; + } else { + throw $e; + } } if ($result) { if ($preserveMtime) { @@ -926,10 +932,10 @@ protected function getHeader($path) { } $result = []; - + // first check if it is an encrypted file at all // We would do query to filecache only if we know that entry in filecache exists - + $info = $this->getCache()->get($path); if (isset($info['encrypted']) && $info['encrypted'] === true) { $firstBlock = $this->readFirstBlock($path);