Skip to content

Commit

Permalink
Merge pull request nextcloud#12090 from AdamWill/google-rename-delete
Browse files Browse the repository at this point in the history
google: delete original after successful rename
  • Loading branch information
MorrisJobke committed Dec 10, 2014
2 parents 3026cdb + 415411a commit e3de510
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/files_external/lib/google.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,22 @@ public function rename($path1, $path2) {
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 {
Expand Down

0 comments on commit e3de510

Please sign in to comment.