Merge pull request #4416 from gvmura/avoid-duplicate-files-google

Avoid duplicate files in google with the same name
This commit is contained in:
Morris Jobke 2017-04-26 01:26:04 -03:00 committed by GitHub
commit 4c2c08f376
1 changed files with 13 additions and 0 deletions

View File

@ -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);