]> source.dussan.org Git - nextcloud-server.git/commitdiff
minor code cleanup
authorJörn Friedrich Dreyer <jfd@butonic.de>
Thu, 12 Jun 2014 08:38:12 +0000 (10:38 +0200)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Wed, 18 Jun 2014 10:53:20 +0000 (12:53 +0200)
lib/private/files/objectstore/abstractobjectstore.php
lib/private/files/objectstore/noopscanner.php

index 43f0a9735942f3e9eaa47ee854c406f3f209d147..8d65e18b6cc75e30d4dfa24955e9529bbd8f5bcd 100644 (file)
@@ -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)) {
index 8971db65dc93f1044d04d8deada9ddd52eefc0eb..59ca17719713edc3795b3dee43f9fc4860d07546 100644 (file)
  */
 
 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;
        }