Skip to content

Commit

Permalink
Merge pull request #4416 from gvmura/avoid-duplicate-files-google
Browse files Browse the repository at this point in the history
Avoid duplicate files in google with the same name
  • Loading branch information
MorrisJobke committed Apr 26, 2017
2 parents d4329f3 + 8613678 commit 4c2c08f
Showing 1 changed file with 13 additions and 0 deletions.
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

0 comments on commit 4c2c08f

Please sign in to comment.