diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-04-26 01:26:04 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-26 01:26:04 -0300 |
commit | 4c2c08f376da6c8229522559ca3b6c9c7d0f5358 (patch) | |
tree | 9d50f40482f28975c15638b8ab0840c720c0000f | |
parent | d4329f33556eaac6e863c2733e2e05964f3d0935 (diff) | |
parent | 8613678462ec24e4a864e3b4fe19d17b35b49c1d (diff) | |
download | nextcloud-server-4c2c08f376da6c8229522559ca3b6c9c7d0f5358.tar.gz nextcloud-server-4c2c08f376da6c8229522559ca3b6c9c7d0f5358.zip |
Merge pull request #4416 from gvmura/avoid-duplicate-files-google
Avoid duplicate files in google with the same name
-rw-r--r-- | apps/files_external/lib/Lib/Storage/Google.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/apps/files_external/lib/Lib/Storage/Google.php b/apps/files_external/lib/Lib/Storage/Google.php index 2211686055e..0a88ccc8d42 100644 --- a/apps/files_external/lib/Lib/Storage/Google.php +++ b/apps/files_external/lib/Lib/Storage/Google.php @@ -386,6 +386,19 @@ class Google extends \OC\Files\Storage\Common { } 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); |