aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorgvmura <gvmura@uniss.it>2017-04-21 09:53:52 +0200
committerroot <gvmura@uniss.it>2017-04-21 11:30:02 +0200
commit0d063c316a18ce8a8c77948dcc6a6ae32452d758 (patch)
tree172fd86c828832cbdcfb10b1bc1e489a446d383c /apps
parentc4bd01456b7fc8e531af1e8cc37dbff4f1ca8578 (diff)
downloadnextcloud-server-0d063c316a18ce8a8c77948dcc6a6ae32452d758.tar.gz
nextcloud-server-0d063c316a18ce8a8c77948dcc6a6ae32452d758.zip
avoid duplicate files in google with the same name
Signed-off-by: gvmura <gvmura@uniss.it>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/Lib/Storage/Google.php13
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);