Skip to content

Commit

Permalink
Only delete if copy succeeded
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Jan 15, 2015
1 parent 01ef533 commit 12ca5d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions lib/private/files/storage/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public function getDirectDownload($path) {
* @param \OCP\Files\Storage $sourceStorage
* @param string $sourceInternalPath
* @param string $targetInternalPath
* @return bool true on success, false if the cross storage copy is not possible
* @return bool
*/
public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
if ($sourceStorage->is_dir($sourceInternalPath)) {
Expand All @@ -482,14 +482,17 @@ public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceIntern
* @param \OCP\Files\Storage $sourceStorage
* @param string $sourceInternalPath
* @param string $targetInternalPath
* @return bool true on success, false if the cross storage copy is not possible
* @return bool
*/
public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
$this->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
if ($sourceStorage->is_dir($sourceInternalPath)) {
$sourceStorage->rmdir($sourceInternalPath);
} else {
$sourceStorage->unlink($sourceInternalPath);
$result = $this->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
if($result) {
if ($sourceStorage->is_dir($sourceInternalPath)) {
$sourceStorage->rmdir($sourceInternalPath);
} else {
$sourceStorage->unlink($sourceInternalPath);
}
}
return $result;
}
}
4 changes: 2 additions & 2 deletions lib/public/files/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,15 @@ public function getDirectDownload($path);
* @param \OCP\Files\Storage $sourceStorage
* @param string $sourceInternalPath
* @param string $targetInternalPath
* @return bool true on success, false if the cross storage copy is not possible
* @return bool
*/
public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath);

/**
* @param \OCP\Files\Storage $sourceStorage
* @param string $sourceInternalPath
* @param string $targetInternalPath
* @return bool true on success, false if the cross storage copy is not possible
* @return bool
*/
public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath);
}

0 comments on commit 12ca5d3

Please sign in to comment.