Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/files/lib/Command/TransferOwnership.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,16 @@ private function copyBetweenStorage(
$source = $sourceStorage->fopen($sourceInternalPath, 'r');
$target = $this->fopen($targetInternalPath, 'w');
[, $result] = \OC_Helper::streamCopy($source, $target);
} catch (\Exception $e) {
$this->logger->debug(
'Fail to copy ' . $sourceInternalPath . ' to ' . $targetInternalPath, ['exception' => $e]
);
if ($GLOBALS['ignore-encryption-error']) {
fwrite(STDERR, " - Skipping '$sourceInternalPath'" . $e->getMessage() . PHP_EOL);
$result = true;
} else {
throw $e;
}
} finally {
if (is_resource($source)) {
fclose($source);
Expand All @@ -825,6 +835,7 @@ private function copyBetweenStorage(
fclose($target);
}
}

if ($result) {
if ($preserveMtime) {
$this->touch($targetInternalPath, $sourceStorage->filemtime($sourceInternalPath));
Expand Down