diff options
Diffstat (limited to 'apps/files_sharing/lib/sharedstorage.php')
-rw-r--r-- | apps/files_sharing/lib/sharedstorage.php | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 33b7f887e19..50957663b34 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -7,6 +7,7 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> + * @author Roeland Jago Douma <roeland@famdouma.nl> * @author scambra <sergio@entrecables.com> * @author Vincent Petry <pvince81@owncloud.com> * @@ -29,11 +30,11 @@ namespace OC\Files\Storage; -use OC\Files\Cache\ChangePropagator; use OC\Files\Filesystem; use OCA\Files_Sharing\ISharedStorage; use OCA\Files_Sharing\Propagator; use OCA\Files_Sharing\SharedMount; +use OCP\Lock\ILockingProvider; /** * Convert target path to source path and pass the function call to the correct storage provider @@ -70,7 +71,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage { * Get the source file path, permissions, and owner for a shared file * * @param string $target Shared target file path - * @return Returns array with the keys path, permissions, and owner or false if not found + * @return array Returns array with the keys path, permissions, and owner or false if not found */ public function getFile($target) { if (!isset($this->files[$target])) { @@ -217,7 +218,13 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage { } public function isReadable($path) { - return $this->file_exists($path); + $isReadable = false; + if ($source = $this->getSourcePath($path)) { + list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source); + $isReadable = $storage->isReadable($internalPath); + } + + return $isReadable && $this->file_exists($path); } public function isUpdatable($path) { @@ -605,4 +612,38 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage { list($targetStorage, $targetInternalPath) = $this->resolvePath($targetInternalPath); return $targetStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } + + /** + * @param string $path + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE + * @param \OCP\Lock\ILockingProvider $provider + * @throws \OCP\Lock\LockedException + */ + public function acquireLock($path, $type, ILockingProvider $provider) { + /** @var \OCP\Files\Storage $targetStorage */ + list($targetStorage, $targetInternalPath) = $this->resolvePath($path); + $targetStorage->acquireLock($targetInternalPath, $type, $provider); + } + + /** + * @param string $path + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE + * @param \OCP\Lock\ILockingProvider $provider + */ + public function releaseLock($path, $type, ILockingProvider $provider) { + /** @var \OCP\Files\Storage $targetStorage */ + list($targetStorage, $targetInternalPath) = $this->resolvePath($path); + $targetStorage->releaseLock($targetInternalPath, $type, $provider); + } + + /** + * @param string $path + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE + * @param \OCP\Lock\ILockingProvider $provider + */ + public function changeLock($path, $type, ILockingProvider $provider) { + /** @var \OCP\Files\Storage $targetStorage */ + list($targetStorage, $targetInternalPath) = $this->resolvePath($path); + $targetStorage->changeLock($targetInternalPath, $type, $provider); + } } |