[Pkg-owncloud-commits] [owncloud] 13/273: minor code cleanup

David Prévot taffit at moszumanska.debian.org
Fri Jul 4 03:12:52 UTC 2014


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

taffit pushed a commit to branch master
in repository owncloud.

commit eca536d8b49ed6a51e54040cd8104397f05defb3
Author: Jörn Friedrich Dreyer <jfd at butonic.de>
Date:   Thu Jun 12 10:38:12 2014 +0200

    minor code cleanup
---
 .../files/objectstore/abstractobjectstore.php      | 13 +++++----
 lib/private/files/objectstore/noopscanner.php      | 33 ++++------------------
 2 files changed, 14 insertions(+), 32 deletions(-)

diff --git a/lib/private/files/objectstore/abstractobjectstore.php b/lib/private/files/objectstore/abstractobjectstore.php
index 43f0a97..8d65e18 100644
--- a/lib/private/files/objectstore/abstractobjectstore.php
+++ b/lib/private/files/objectstore/abstractobjectstore.php
@@ -24,10 +24,12 @@ abstract class AbstractObjectStore extends \OC\Files\Storage\Common {
 
 	/**
 	 * @param string $urn the unified resource name used to identify the object
+	 * @param string $tmpFile path to the local temporary file that the object
+	 *        should be loaded from
 	 * @return void
 	 * @throws Exception when something goes wrong, message will be logged
 	 */
-	abstract protected function deleteObject($urn);
+	abstract protected function createObject($urn, $tmpFile = null);
 
 	/**
 	 * @param string $urn the unified resource name used to identify the object
@@ -40,12 +42,10 @@ abstract class AbstractObjectStore extends \OC\Files\Storage\Common {
 
 	/**
 	 * @param string $urn the unified resource name used to identify the object
-	 * @param string $tmpFile path to the local temporary file that the object
-	 *        should be loaded from
 	 * @return void
 	 * @throws Exception when something goes wrong, message will be logged
 	 */
-	abstract protected function createObject($urn, $tmpFile = null);
+	abstract protected function deleteObject($urn);
 
 	/**
 	 * @var \OC\User\User $user
@@ -411,8 +411,11 @@ abstract class AbstractObjectStore extends \OC\Files\Storage\Common {
 	}
 
 	/**
+	 * Override this method if you need a different unique resource identifier for your object storage implementation.
+	 * The default implementations just appends the fileId to 'urn:oid:'. Make sure the URN is unique over all users.
+	 * You may need a mapping table to store your URN if it cannot be generated from the fileid.
 	 * @param int $fileId the fileid
-	 * @return null|string
+	 * @return null|string the unified resource name used to identify the object
 	 */
 	protected function getURN($fileId) {
 		if (is_numeric($fileId)) {
diff --git a/lib/private/files/objectstore/noopscanner.php b/lib/private/files/objectstore/noopscanner.php
index 8971db6..59ca177 100644
--- a/lib/private/files/objectstore/noopscanner.php
+++ b/lib/private/files/objectstore/noopscanner.php
@@ -19,34 +19,13 @@
  */
 
 namespace OC\Files\ObjectStore;
+use \OC\Files\Cache\Scanner;
+use \OC\Files\Storage\Storage;
 
-class NoopScanner extends \OC\Files\Cache\Scanner {
+class NoopScanner extends Scanner {
 
-	/**
-	 * get all the metadata of a file or folder
-	 * *
-	 *
-	 * @param string $path
-	 * @return array with metadata of the file
-	 */
-	public function getData($path) {
-		if (!$this->storage->isReadable($path)) {
-			//cant read, nothing we can do
-			\OCP\Util::writeLog('OC\Files\ObjectStore\NoopScanner', "!!! Path '$path' is not readable !!!", \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['permissions'] = $this->storage->getPermissions($path);
-		return $data;
+	public function __construct(Storage $storage) {
+		//we don't need the storage, so do nothing here
 	}
 
 	/**
@@ -81,7 +60,7 @@ class NoopScanner extends \OC\Files\Cache\Scanner {
 	 * @param int $reuse
 	 * @return int the size of the scanned folder or -1 if the size is unknown at this stage
 	 */
-	public function scanChildren($path, $recursive = \OC\Files\Storage\Storage::SCAN_RECURSIVE, $reuse = -1) {
+	public function scanChildren($path, $recursive = Storage::SCAN_RECURSIVE, $reuse = -1) {
 		$size = 0;
 		return $size;
 	}

-- 
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