]> source.dussan.org Git - nextcloud-server.git/commitdiff
only trigger locking on lockingstorages
authorRobin Appelman <icewind@owncloud.com>
Mon, 4 Jan 2016 13:11:21 +0000 (14:11 +0100)
committerRobin Appelman <icewind@owncloud.com>
Thu, 14 Jan 2016 12:01:43 +0000 (13:01 +0100)
lib/private/files/cache/scanner.php
lib/private/files/storage/wrapper/wrapper.php
lib/private/files/view.php

index 9215114937450e7987c71d1e44a89949b27a2aef..743b50f54a923b491c14cab816ed49d7591cb1ef 100644 (file)
@@ -38,6 +38,7 @@ use OC\Files\Filesystem;
 use OC\Hooks\BasicEmitter;
 use OCP\Config;
 use OCP\Files\Cache\IScanner;
+use OCP\Files\Storage\ILockingStorage;
 use OCP\Lock\ILockingProvider;
 
 /**
@@ -132,7 +133,9 @@ class Scanner extends BasicEmitter implements IScanner {
                        and !Filesystem::isFileBlacklisted($file)
                ) {
                        if ($lock) {
-                               $this->storage->acquireLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
+                               if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
+                                       $this->storage->acquireLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
+                               }
                        }
                        $this->emit('\OC\Files\Cache\Scanner', 'scanFile', array($file, $this->storageId));
                        \OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId));
@@ -192,7 +195,9 @@ class Scanner extends BasicEmitter implements IScanner {
                                $this->removeFromCache($file);
                        }
                        if ($lock) {
-                               $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
+                               if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
+                                       $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
+                               }
                        }
                        return $data;
                }
@@ -259,7 +264,9 @@ class Scanner extends BasicEmitter implements IScanner {
                        $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
                }
                if ($lock) {
-                       $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
+                       if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
+                               $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
+                       }
                }
                $data = $this->scanFile($path, $reuse, -1, null, $lock);
                if ($data and $data['mimetype'] === 'httpd/unix-directory') {
@@ -267,7 +274,9 @@ class Scanner extends BasicEmitter implements IScanner {
                        $data['size'] = $size;
                }
                if ($lock) {
-                       $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
+                       if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
+                               $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
+                       }
                }
                return $data;
        }
index 472c60b5faac897c63fe13227f2b1d3568cbc81b..c632aa399e1cce39b156f045885b7ef592188579 100644 (file)
 namespace OC\Files\Storage\Wrapper;
 
 use OCP\Files\InvalidPathException;
+use OCP\Files\Storage\ILockingStorage;
 use OCP\Lock\ILockingProvider;
 
-class Wrapper implements \OC\Files\Storage\Storage {
+class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
        /**
         * @var \OC\Files\Storage\Storage $storage
         */
@@ -583,7 +584,9 @@ class Wrapper implements \OC\Files\Storage\Storage {
         * @throws \OCP\Lock\LockedException
         */
        public function acquireLock($path, $type, ILockingProvider $provider) {
-               $this->storage->acquireLock($path, $type, $provider);
+               if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
+                       $this->storage->acquireLock($path, $type, $provider);
+               }
        }
 
        /**
@@ -592,7 +595,9 @@ class Wrapper implements \OC\Files\Storage\Storage {
         * @param \OCP\Lock\ILockingProvider $provider
         */
        public function releaseLock($path, $type, ILockingProvider $provider) {
-               $this->storage->releaseLock($path, $type, $provider);
+               if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
+                       $this->storage->releaseLock($path, $type, $provider);
+               }
        }
 
        /**
@@ -601,6 +606,8 @@ class Wrapper implements \OC\Files\Storage\Storage {
         * @param \OCP\Lock\ILockingProvider $provider
         */
        public function changeLock($path, $type, ILockingProvider $provider) {
-               $this->storage->changeLock($path, $type, $provider);
+               if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
+                       $this->storage->changeLock($path, $type, $provider);
+               }
        }
 }
index 6f8a6db9f99a7315b97b05646cdaa9bac6433b9c..55b8da165e1de5983f1dc9468e025e9ffd63a845 100644 (file)
@@ -43,7 +43,6 @@
 namespace OC\Files;
 
 use Icewind\Streams\CallbackWrapper;
-use OC\Files\Cache\Updater;
 use OC\Files\Mount\MoveableMount;
 use OC\Files\Storage\Storage;
 use OC\User\User;
@@ -53,6 +52,7 @@ use OCP\Files\InvalidCharacterInPathException;
 use OCP\Files\InvalidPathException;
 use OCP\Files\NotFoundException;
 use OCP\Files\ReservedWordException;
+use OCP\Files\Storage\ILockingStorage;
 use OCP\IUser;
 use OCP\Lock\ILockingProvider;
 use OCP\Lock\LockedException;
@@ -1835,11 +1835,14 @@ class View {
                $mount = $this->getMountForLock($absolutePath, $lockMountPoint);
                if ($mount) {
                        try {
-                               $mount->getStorage()->acquireLock(
-                                       $mount->getInternalPath($absolutePath),
-                                       $type,
-                                       $this->lockingProvider
-                               );
+                               $storage = $mount->getStorage();
+                               if ($storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
+                                       $storage->acquireLock(
+                                               $mount->getInternalPath($absolutePath),
+                                               $type,
+                                               $this->lockingProvider
+                                       );
+                               }
                        } catch (\OCP\Lock\LockedException $e) {
                                // rethrow with the a human-readable path
                                throw new \OCP\Lock\LockedException(
@@ -1873,11 +1876,14 @@ class View {
                $mount = $this->getMountForLock($absolutePath, $lockMountPoint);
                if ($mount) {
                        try {
-                               $mount->getStorage()->changeLock(
-                                       $mount->getInternalPath($absolutePath),
-                                       $type,
-                                       $this->lockingProvider
-                               );
+                               $storage = $mount->getStorage();
+                               if ($storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
+                                       $storage->changeLock(
+                                               $mount->getInternalPath($absolutePath),
+                                               $type,
+                                               $this->lockingProvider
+                                       );
+                               }
                        } catch (\OCP\Lock\LockedException $e) {
                                // rethrow with the a human-readable path
                                throw new \OCP\Lock\LockedException(
@@ -1908,11 +1914,14 @@ class View {
 
                $mount = $this->getMountForLock($absolutePath, $lockMountPoint);
                if ($mount) {
-                       $mount->getStorage()->releaseLock(
-                               $mount->getInternalPath($absolutePath),
-                               $type,
-                               $this->lockingProvider
-                       );
+                       $storage = $mount->getStorage();
+                       if ($storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
+                               $storage->releaseLock(
+                                       $mount->getInternalPath($absolutePath),
+                                       $type,
+                                       $this->lockingProvider
+                               );
+                       }
                }
 
                return true;