Catch file transfer error and stop transfer ownership command

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2019-11-27 09:21:17 +01:00
parent a2046db6d0
commit 70f4e7e10a
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
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");