summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Lib/Storage/Google.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib/Lib/Storage/Google.php')
-rw-r--r--apps/files_external/lib/Lib/Storage/Google.php18
1 files changed, 16 insertions, 2 deletions
diff --git a/apps/files_external/lib/Lib/Storage/Google.php b/apps/files_external/lib/Lib/Storage/Google.php
index 2a1ff768e2c..96f12800c10 100644
--- a/apps/files_external/lib/Lib/Storage/Google.php
+++ b/apps/files_external/lib/Lib/Storage/Google.php
@@ -97,6 +97,9 @@ class Google extends \OC\Files\Storage\Common {
private function getDriveFile($path) {
// Remove leading and trailing slashes
$path = trim($path, '/');
+ if ($path === '.') {
+ $path = '';
+ }
if (isset($this->driveFiles[$path])) {
return $this->driveFiles[$path];
} else if ($path === '') {
@@ -138,7 +141,7 @@ class Google extends \OC\Files\Storage\Common {
if ($pos !== false) {
$pathWithoutExt = substr($path, 0, $pos);
$file = $this->getDriveFile($pathWithoutExt);
- if ($file) {
+ if ($file && $this->isGoogleDocFile($file)) {
// Switch cached Google_Service_Drive_DriveFile to the correct index
unset($this->driveFiles[$pathWithoutExt]);
$this->driveFiles[$path] = $file;
@@ -208,6 +211,17 @@ class Google extends \OC\Files\Storage\Common {
}
}
+ /**
+ * Returns whether the given drive file is a Google Doc file
+ *
+ * @param \Google_Service_Drive_DriveFile
+ *
+ * @return true if the file is a Google Doc file, false otherwise
+ */
+ private function isGoogleDocFile($file) {
+ return $this->getGoogleDocExtension($file->getMimeType()) !== '';
+ }
+
public function mkdir($path) {
if (!$this->is_dir($path)) {
$parentFolder = $this->getDriveFile(dirname($path));
@@ -312,7 +326,7 @@ class Google extends \OC\Files\Storage\Common {
$stat['size'] = 0;
} else {
// Check if this is a Google Doc
- if ($this->getMimeType($path) !== $file->getMimeType()) {
+ if ($this->isGoogleDocFile($file)) {
// Return unknown file size
$stat['size'] = \OCP\Files\FileInfo::SPACE_UNKNOWN;
} else {