summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-19 09:13:35 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-19 09:13:35 +0100
commitae2304f23f04f1d6c84f2a049a4b0fdc0c9023c6 (patch)
tree8454bba2b87eead5b0d7d711b4e1bbbe78c18fe0 /apps/files_external
parentf6e61a296f67f71a1c6d5d5bf8d7e891cd708b43 (diff)
parent075dd54f6c4633237e2eef5fe808632c591aef4b (diff)
downloadnextcloud-server-ae2304f23f04f1d6c84f2a049a4b0fdc0c9023c6.tar.gz
nextcloud-server-ae2304f23f04f1d6c84f2a049a4b0fdc0c9023c6.zip
Merge pull request #22405 from owncloud/gdrive-mimetype-and-office-fixes
Fix GDrive handling of office files
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/lib/google.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index f496fc77574..ee7a7383615 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -264,7 +264,7 @@ class Google extends \OC\Files\Storage\Common {
foreach ($children->getItems() as $child) {
$name = $child->getTitle();
// Check if this is a Google Doc i.e. no extension in name
- if ($child->getFileExtension() === ''
+ if (empty($child->getFileExtension())
&& $child->getMimeType() !== self::FOLDER
) {
$name .= '.'.$this->getGoogleDocExtension($child->getMimeType());
@@ -368,8 +368,14 @@ class Google extends \OC\Files\Storage\Common {
public function rename($path1, $path2) {
$file = $this->getDriveFile($path1);
if ($file) {
+ $newFile = $this->getDriveFile($path2);
if (dirname($path1) === dirname($path2)) {
- $file->setTitle(basename(($path2)));
+ if ($newFile) {
+ // rename to the name of the target file, could be an office file without extension
+ $file->setTitle($newFile->getTitle());
+ } else {
+ $file->setTitle(basename(($path2)));
+ }
} else {
// Change file parent
$parentFolder2 = $this->getDriveFile(dirname($path2));
@@ -394,8 +400,11 @@ class Google extends \OC\Files\Storage\Common {
if ($result) {
$this->setDriveFile($path1, false);
$this->setDriveFile($path2, $result);
- if ($oldfile) {
- $this->service->files->delete($oldfile->getId());
+ if ($oldfile && $newFile) {
+ // only delete if they have a different id (same id can happen for part files)
+ if ($newFile->getId() !== $oldfile->getId()) {
+ $this->service->files->delete($oldfile->getId());
+ }
}
}
return (bool)$result;