From a49e873d3fa513136bfdf1d71bbc2bbcd61d3650 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 21 Nov 2013 19:15:11 +0100 Subject: [PATCH 1/2] Return plausible isReadable() default impl for ext storage When an ext storage doesn't implement isReadable(), always returning true made the file scanner believe that the file exists and creates a cache entry with the size zero. This fix makes the default impl of isReadable() use file_exists(). Fixes #5940 --- apps/files_external/lib/streamwrapper.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index 4a63dfb6e0..a086f411f5 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -42,11 +42,16 @@ abstract class StreamWrapper extends Common { } public function isReadable($path) { - return true; //not properly supported + // at least check whether it exists + // subclasses might want to implement this more thoroughly + return $this->file_exists($path); } public function isUpdatable($path) { - return true; //not properly supported + // at least check whether it exists + // subclasses might want to implement this more thoroughly + // a non-existing file/folder isn't updatable + return $this->file_exists($path); } public function file_exists($path) { From c62cce826994291c528e7cc90da5be9fc94ebaf2 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 22 Nov 2013 15:24:23 +0100 Subject: [PATCH 2/2] Moved default isReadable/isUpdatable impl into Common class Also adjusted all ext storage backends to not override these when the default behavior is expected. --- apps/files_external/lib/amazons3.php | 8 -------- apps/files_external/lib/dropbox.php | 8 -------- apps/files_external/lib/google.php | 4 ---- apps/files_external/lib/sftp.php | 8 -------- apps/files_external/lib/streamwrapper.php | 13 ------------- apps/files_external/lib/swift.php | 8 -------- apps/files_external/lib/webdav.php | 8 -------- lib/private/files/storage/common.php | 13 +++++++++++++ 8 files changed, 13 insertions(+), 57 deletions(-) diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index c08a266b48..9a682fb2d4 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -300,14 +300,6 @@ class AmazonS3 extends \OC\Files\Storage\Common { return false; } - public function isReadable($path) { - return true; - } - - public function isUpdatable($path) { - return true; - } - public function unlink($path) { $path = $this->normalizePath($path); diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php index b6deab6e5a..6e464f4e28 100755 --- a/apps/files_external/lib/dropbox.php +++ b/apps/files_external/lib/dropbox.php @@ -146,14 +146,6 @@ class Dropbox extends \OC\Files\Storage\Common { return false; } - public function isReadable($path) { - return $this->file_exists($path); - } - - public function isUpdatable($path) { - return $this->file_exists($path); - } - public function file_exists($path) { if ($path == '' || $path == '/') { return true; diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index b63b5885de..426caf008e 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -317,10 +317,6 @@ class Google extends \OC\Files\Storage\Common { } } - public function isReadable($path) { - return $this->file_exists($path); - } - public function isUpdatable($path) { $file = $this->getDriveFile($path); if ($file) { diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index 7c5aed5aa0..bcc4c5eafd 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -180,14 +180,6 @@ class SFTP extends \OC\Files\Storage\Common { return false; } - public function isReadable($path) { - return true; - } - - public function isUpdatable($path) { - return true; - } - public function file_exists($path) { try { return $this->client->stat($this->absPath($path)) !== false; diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index a086f411f5..23c5f91a2f 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -41,19 +41,6 @@ abstract class StreamWrapper extends Common { return filetype($this->constructUrl($path)); } - public function isReadable($path) { - // at least check whether it exists - // subclasses might want to implement this more thoroughly - return $this->file_exists($path); - } - - public function isUpdatable($path) { - // at least check whether it exists - // subclasses might want to implement this more thoroughly - // a non-existing file/folder isn't updatable - return $this->file_exists($path); - } - public function file_exists($path) { return file_exists($this->constructUrl($path)); } diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index bb650dacc7..86938ef3bb 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -268,14 +268,6 @@ class Swift extends \OC\Files\Storage\Common { } } - public function isReadable($path) { - return true; - } - - public function isUpdatable($path) { - return true; - } - public function unlink($path) { $path = $this->normalizePath($path); diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 5857c59dcf..0837222e51 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -134,14 +134,6 @@ class DAV extends \OC\Files\Storage\Common{ } } - public function isReadable($path) { - return true;//not properly supported - } - - public function isUpdatable($path) { - return true;//not properly supported - } - public function file_exists($path) { $this->init(); $path=$this->cleanPath($path); diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index f99bbc9ae5..678bf41902 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -51,6 +51,19 @@ abstract class Common implements \OC\Files\Storage\Storage { } } + public function isReadable($path) { + // at least check whether it exists + // subclasses might want to implement this more thoroughly + return $this->file_exists($path); + } + + public function isUpdatable($path) { + // at least check whether it exists + // subclasses might want to implement this more thoroughly + // a non-existing file/folder isn't updatable + return $this->file_exists($path); + } + public function isCreatable($path) { if ($this->is_dir($path) && $this->isUpdatable($path)) { return true;