summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-12-10 09:10:17 +0100
committerMorris Jobke <hey@morrisjobke.de>2014-12-10 09:10:17 +0100
commite3de51078d4c9eb26eb7f09a98ff97c371ae9180 (patch)
treef39ff8f56ab236514f2b69c2cde7db8074bf9777 /apps
parent3026cdbc809795099596d0fa8d934326ae81ac3e (diff)
parent415411a3d5625cf3b13c7e0c0a25d378b1e49a8a (diff)
downloadnextcloud-server-e3de51078d4c9eb26eb7f09a98ff97c371ae9180.tar.gz
nextcloud-server-e3de51078d4c9eb26eb7f09a98ff97c371ae9180.zip
Merge pull request #12090 from AdamWill/google-rename-delete
google: delete original after successful rename
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/google.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index c414e34fad4..bd9bdce2a67 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -370,10 +370,22 @@ class Google extends \OC\Files\Storage\Common {
return false;
}
}
+ // We need to get the object for the existing file with the same
+ // name (if there is one) before we do the patch. If oldfile
+ // exists and is a directory we have to delete it before we
+ // do the rename too.
+ $oldfile = $this->getDriveFile($path2);
+ if ($oldfile && $this->is_dir($path2)) {
+ $this->rmdir($path2);
+ $oldfile = false;
+ }
$result = $this->service->files->patch($file->getId(), $file);
if ($result) {
$this->setDriveFile($path1, false);
$this->setDriveFile($path2, $result);
+ if ($oldfile) {
+ $this->service->files->delete($oldfile->getId());
+ }
}
return (bool)$result;
} else {