Skip to content

Commit e3de510

Browse files
committed
Merge pull request #12090 from AdamWill/google-rename-delete
google: delete original after successful rename
2 parents 3026cdb + 415411a commit e3de510

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

apps/files_external/lib/google.php

+12
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,22 @@ public function rename($path1, $path2) {
370370
return false;
371371
}
372372
}
373+
// We need to get the object for the existing file with the same
374+
// name (if there is one) before we do the patch. If oldfile
375+
// exists and is a directory we have to delete it before we
376+
// do the rename too.
377+
$oldfile = $this->getDriveFile($path2);
378+
if ($oldfile && $this->is_dir($path2)) {
379+
$this->rmdir($path2);
380+
$oldfile = false;
381+
}
373382
$result = $this->service->files->patch($file->getId(), $file);
374383
if ($result) {
375384
$this->setDriveFile($path1, false);
376385
$this->setDriveFile($path2, $result);
386+
if ($oldfile) {
387+
$this->service->files->delete($oldfile->getId());
388+
}
377389
}
378390
return (bool)$result;
379391
} else {

0 commit comments

Comments
 (0)