Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoid duplicate files in google with the same name
Signed-off-by: gvmura <[email protected]>
  • Loading branch information
gvmura committed Apr 21, 2017
commit 0d063c316a18ce8a8c77948dcc6a6ae32452d758
13 changes: 13 additions & 0 deletions apps/files_external/lib/Lib/Storage/Google.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,19 @@ public function unlink($path) {
}

public function rename($path1, $path2) {
// Avoid duplicate files with the same name
$testRegex = '/^.+\.ocTransferId\d+\.part$/';
if (preg_match($testRegex, $path1)) {
if ($this->is_file($path2)) {
$testFile2 = $this->getDriveFile($path2);
if ($testFile2) {
$this->service->files->trash($testFile2->getId());
\OCP\Util::writeLog('files_external', 'trash file '.$path2.
' for renaming '.$path1.' on Google Drive.', \OCP\Util::DEBUG);
}
}
}

$file = $this->getDriveFile($path1);
if ($file) {
$newFile = $this->getDriveFile($path2);
Expand Down