[Pkg-owncloud-commits] [owncloud] 112/165: Introduce Storage::getData() to allow storage implementations more control over the data array

David Prévot taffit at moszumanska.debian.org
Thu Apr 23 04:06:43 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 92b60e36de8d89e8ea7c4781a8c5d5fa4371b7c3
Author: Thomas Müller <thomas.mueller at tmit.eu>
Date:   Mon Apr 20 14:25:39 2015 +0200

    Introduce Storage::getData() to allow storage implementations more control over the data array
---
 lib/private/files/cache/scanner.php              | 13 +++----------
 lib/private/files/storage/common.php             | 17 +++++++++++++++++
 lib/private/files/storage/storage.php            |  6 ++++++
 lib/private/files/storage/wrapper/encryption.php | 23 +++++++++++++++++++++++
 lib/private/files/storage/wrapper/wrapper.php    |  8 ++++++++
 5 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 0878b6c..c1ba7c0 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -109,17 +109,10 @@ class Scanner extends BasicEmitter {
 			\OCP\Util::writeLog('OC\Files\Cache\Scanner', "!!! Path '$path' is not accessible or present !!!", \OCP\Util::DEBUG);
 			return null;
 		}
-		$data = array();
-		$data['mimetype'] = $this->storage->getMimeType($path);
-		$data['mtime'] = $this->storage->filemtime($path);
-		if ($data['mimetype'] == 'httpd/unix-directory') {
-			$data['size'] = -1; //unknown
-		} else {
-			$data['size'] = $this->storage->filesize($path);
-		}
-		$data['etag'] = $this->storage->getETag($path);
-		$data['storage_mtime'] = $data['mtime'];
+
+		$data = $this->storage->getData($path);
 		$data['permissions'] = $permissions;
+
 		return $data;
 	}
 
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index 66ed713..0294fc4 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -580,4 +580,21 @@ abstract class Common implements Storage {
 		}
 		return $result;
 	}
+
+	/**
+	 * @inheritdoc
+	 */
+	public function getData($path) {
+		$data = [];
+		$data['mimetype'] = $this->getMimeType($path);
+		$data['mtime'] = $this->filemtime($path);
+		if ($data['mimetype'] == 'httpd/unix-directory') {
+			$data['size'] = -1; //unknown
+		} else {
+			$data['size'] = $this->filesize($path);
+		}
+		$data['etag'] = $this->getETag($path);
+		$data['storage_mtime'] = $data['mtime'];
+		return $data;
+	}
 }
diff --git a/lib/private/files/storage/storage.php b/lib/private/files/storage/storage.php
index 4b75fa9..9fda743 100644
--- a/lib/private/files/storage/storage.php
+++ b/lib/private/files/storage/storage.php
@@ -70,4 +70,10 @@ interface Storage extends \OCP\Files\Storage {
 	 */
 	public function getStorageCache();
 
+	/**
+	 * @param $path
+	 * @return array
+	 */
+	public function getData($path);
+
 }
diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php
index 01bd861..df91b71 100644
--- a/lib/private/files/storage/wrapper/encryption.php
+++ b/lib/private/files/storage/wrapper/encryption.php
@@ -111,6 +111,29 @@ class Encryption extends Wrapper {
 	}
 
 	/**
+	 * @param $path
+	 * @return array
+	 */
+	public function getData($path) {
+		$data = $this->storage->getData($path);
+		$fullPath = $this->getFullPath($path);
+
+		if (isset($this->unencryptedSize[$fullPath])) {
+			$size = $this->unencryptedSize[$fullPath];
+
+			$data['encrypted'] = true;
+			$data['size'] = $size;
+		} else {
+			$info = $this->getCache()->get($path);
+			if (isset($info['fileid']) && $info['encrypted']) {
+				$data['encrypted'] = true;
+				$data['size'] = $info['size'];
+			}
+		}
+
+		return $data;
+	}
+	/**
 	 * see http://php.net/manual/en/function.file_get_contents.php
 	 *
 	 * @param string $path
diff --git a/lib/private/files/storage/wrapper/wrapper.php b/lib/private/files/storage/wrapper/wrapper.php
index 2552c92..0bea457 100644
--- a/lib/private/files/storage/wrapper/wrapper.php
+++ b/lib/private/files/storage/wrapper/wrapper.php
@@ -525,4 +525,12 @@ class Wrapper implements \OC\Files\Storage\Storage {
 	public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
 		return $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
 	}
+
+	/**
+	 * @param $path
+	 * @return array
+	 */
+	public function getData($path) {
+		return $this->storage->getData($path);
+	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list