Merge pull request #17913 from nextcloud/fix/transfer-ownership-move-files-error-handling

Catch file transfer error and stop transfer ownership command
This commit is contained in:
Roeland Jago Douma 2019-12-04 13:53:43 +01:00 committed by GitHub
commit 50985e5461
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -215,6 +215,9 @@ class OwnershipTransferService {
return $shares;
}
/**
* @throws TransferOwnershipException
*/
protected function transferFiles(string $sourceUid,
string $sourcePath,
string $finalTarget,
@ -228,7 +231,9 @@ class OwnershipTransferService {
$view->mkdir($finalTarget);
$finalTarget = $finalTarget . '/' . basename($sourcePath);
}
$view->rename($sourcePath, $finalTarget);
if ($view->rename($sourcePath, $finalTarget) === false) {
throw new TransferOwnershipException("Could not transfer files", 1);
}
if (!is_dir("$sourceUid/files")) {
// because the files folder is moved away we need to recreate it
$view->mkdir("$sourceUid/files");