diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/cache/scanner.php | 17 | ||||
-rw-r--r-- | lib/private/files/storage/wrapper/wrapper.php | 15 | ||||
-rw-r--r-- | lib/private/files/view.php | 41 |
3 files changed, 49 insertions, 24 deletions
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php index 92151149374..743b50f54a9 100644 --- a/lib/private/files/cache/scanner.php +++ b/lib/private/files/cache/scanner.php @@ -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; } diff --git a/lib/private/files/storage/wrapper/wrapper.php b/lib/private/files/storage/wrapper/wrapper.php index 472c60b5faa..c632aa399e1 100644 --- a/lib/private/files/storage/wrapper/wrapper.php +++ b/lib/private/files/storage/wrapper/wrapper.php @@ -26,9 +26,10 @@ 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); + } } } diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 6f8a6db9f99..55b8da165e1 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -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; |