summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authoricewind1991 <robin@icewind.nl>2014-06-17 17:40:05 +0200
committericewind1991 <robin@icewind.nl>2014-06-17 17:40:05 +0200
commit8d1cf79152b16b11e8be3bc6cc57f5a9e72b04dd (patch)
treeef158aadc779e95845384783bbe668abed4c2d85 /lib
parentcce58368ad03f4ef3d8a1ad3e26e09fc51ca716a (diff)
parent07fdeba50b47848c995d38408635020e08cecb19 (diff)
downloadnextcloud-server-8d1cf79152b16b11e8be3bc6cc57f5a9e72b04dd.tar.gz
nextcloud-server-8d1cf79152b16b11e8be3bc6cc57f5a9e72b04dd.zip
Merge pull request #8399 from owncloud/server-server-sharing
Add server<->server sharing
Diffstat (limited to 'lib')
-rw-r--r--lib/private/connector/sabre/directory.php3
-rw-r--r--lib/private/connector/sabre/file.php2
-rw-r--r--lib/private/connector/sabre/objecttree.php23
-rw-r--r--lib/private/files/cache/cache.php10
-rw-r--r--lib/private/files/storage/common.php28
-rw-r--r--lib/private/files/storage/home.php7
-rw-r--r--lib/private/files/storage/storage.php9
-rw-r--r--lib/private/files/storage/wrapper/wrapper.php26
-rw-r--r--lib/private/files/view.php60
-rw-r--r--lib/private/helper.php2
-rw-r--r--lib/private/share/share.php6
11 files changed, 115 insertions, 61 deletions
diff --git a/lib/private/connector/sabre/directory.php b/lib/private/connector/sabre/directory.php
index aa467cec535..9904c3525c4 100644
--- a/lib/private/connector/sabre/directory.php
+++ b/lib/private/connector/sabre/directory.php
@@ -202,7 +202,8 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node
* @return array
*/
public function getQuotaInfo() {
- $storageInfo = OC_Helper::getStorageInfo($this->path);
+ $path = \OC\Files\Filesystem::getView()->getRelativePath($this->info->getPath());
+ $storageInfo = OC_Helper::getStorageInfo($path);
return array(
$storageInfo['used'],
$storageInfo['free']
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 4e90d46ad41..7591cc5c066 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -140,7 +140,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements \Sabre\
if (\OC_Util::encryptedFiles()) {
throw new \Sabre\DAV\Exception\ServiceUnavailable();
} else {
- return $this->fileView->fopen($this->path, 'rb');
+ return $this->fileView->fopen(ltrim($this->path, '/'), 'rb');
}
}
diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php
index c55a392bca0..f2578e3c097 100644
--- a/lib/private/connector/sabre/objecttree.php
+++ b/lib/private/connector/sabre/objecttree.php
@@ -10,6 +10,7 @@ namespace OC\Connector\Sabre;
use OC\Files\FileInfo;
use OC\Files\Filesystem;
+use OC\Files\Mount\MoveableMount;
class ObjectTree extends \Sabre\DAV\ObjectTree {
@@ -19,6 +20,11 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
protected $fileView;
/**
+ * @var \OC\Files\Mount\Manager
+ */
+ protected $mountManager;
+
+ /**
* Creates the object
*
* This method expects the rootObject to be passed as a parameter
@@ -29,10 +35,12 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
/**
* @param \Sabre\DAV\ICollection $rootNode
* @param \OC\Files\View $view
+ * @param \OC\Files\Mount\Manager $mountManager
*/
- public function init(\Sabre\DAV\ICollection $rootNode, \OC\Files\View $view) {
+ public function init(\Sabre\DAV\ICollection $rootNode, \OC\Files\View $view, \OC\Files\Mount\Manager $mountManager) {
$this->rootNode = $rootNode;
$this->fileView = $view;
+ $this->mountManager = $mountManager;
}
/**
@@ -115,14 +123,15 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
list($sourceDir,) = \Sabre\DAV\URLUtil::splitPath($sourcePath);
list($destinationDir,) = \Sabre\DAV\URLUtil::splitPath($destinationPath);
- $isShareMountPoint = false;
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath( '/' . \OCP\User::getUser() . '/files/' . $sourcePath);
- if ($storage instanceof \OC\Files\Storage\Shared && !$internalPath) {
- $isShareMountPoint = true;
+ $isMovableMount = false;
+ $sourceMount = $this->mountManager->find($this->fileView->getAbsolutePath($sourcePath));
+ $internalPath = $sourceMount->getInternalPath($this->fileView->getAbsolutePath($sourcePath));
+ if ($sourceMount instanceof MoveableMount && $internalPath === '') {
+ $isMovableMount = true;
}
// check update privileges
- if (!$this->fileView->isUpdatable($sourcePath) && !$isShareMountPoint) {
+ if (!$this->fileView->isUpdatable($sourcePath) && !$isMovableMount) {
throw new \Sabre\DAV\Exception\Forbidden();
}
if ($sourceDir !== $destinationDir) {
@@ -132,7 +141,7 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
if (!$this->fileView->isUpdatable($destinationDir)) {
throw new \Sabre\DAV\Exception\Forbidden();
}
- if (!$this->fileView->isDeletable($sourcePath)) {
+ if (!$this->fileView->isDeletable($sourcePath) && !$isMovableMount) {
throw new \Sabre\DAV\Exception\Forbidden();
}
}
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index bfd280a91a1..48c57e2e439 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -22,20 +22,20 @@ class Cache {
/**
* @var array partial data for the cache
*/
- private $partial = array();
+ protected $partial = array();
/**
* @var string
*/
- private $storageId;
+ protected $storageId;
/**
* @var Storage $storageCache
*/
- private $storageCache;
+ protected $storageCache;
- private static $mimetypeIds = array();
- private static $mimetypes = array();
+ protected static $mimetypeIds = array();
+ protected static $mimetypes = array();
/**
* @param \OC\Files\Storage\Storage|string $storage
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index 4d5a2078ef7..ecc75298b66 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -287,31 +287,43 @@ abstract class Common implements \OC\Files\Storage\Storage {
return $this->filemtime($path) > $time;
}
- public function getCache($path = '') {
+ public function getCache($path = '', $storage = null) {
+ if (!$storage) {
+ $storage = $this;
+ }
if (!isset($this->cache)) {
- $this->cache = new \OC\Files\Cache\Cache($this);
+ $this->cache = new \OC\Files\Cache\Cache($storage);
}
return $this->cache;
}
- public function getScanner($path = '') {
+ public function getScanner($path = '', $storage = null) {
+ if (!$storage) {
+ $storage = $this;
+ }
if (!isset($this->scanner)) {
- $this->scanner = new \OC\Files\Cache\Scanner($this);
+ $this->scanner = new \OC\Files\Cache\Scanner($storage);
}
return $this->scanner;
}
- public function getWatcher($path = '') {
+ public function getWatcher($path = '', $storage = null) {
+ if (!$storage) {
+ $storage = $this;
+ }
if (!isset($this->watcher)) {
- $this->watcher = new \OC\Files\Cache\Watcher($this);
+ $this->watcher = new \OC\Files\Cache\Watcher($storage);
$this->watcher->setPolicy(\OC::$server->getConfig()->getSystemValue('filesystem_check_changes', Watcher::CHECK_ONCE));
}
return $this->watcher;
}
- public function getStorageCache() {
+ public function getStorageCache($storage = null) {
+ if (!$storage) {
+ $storage = $this;
+ }
if (!isset($this->storageCache)) {
- $this->storageCache = new \OC\Files\Cache\Storage($this);
+ $this->storageCache = new \OC\Files\Cache\Storage($storage);
}
return $this->storageCache;
}
diff --git a/lib/private/files/storage/home.php b/lib/private/files/storage/home.php
index f66096f6d9c..214deede620 100644
--- a/lib/private/files/storage/home.php
+++ b/lib/private/files/storage/home.php
@@ -49,9 +49,12 @@ class Home extends Local {
/**
* @return \OC\Files\Cache\HomeCache
*/
- public function getCache($path = '') {
+ public function getCache($path = '', $storage = null) {
+ if (!$storage) {
+ $storage = $this;
+ }
if (!isset($this->cache)) {
- $this->cache = new \OC\Files\Cache\HomeCache($this);
+ $this->cache = new \OC\Files\Cache\HomeCache($storage);
}
return $this->cache;
}
diff --git a/lib/private/files/storage/storage.php b/lib/private/files/storage/storage.php
index f085a0590b4..2139f464821 100644
--- a/lib/private/files/storage/storage.php
+++ b/lib/private/files/storage/storage.php
@@ -19,17 +19,19 @@ interface Storage extends \OCP\Files\Storage {
* get a cache instance for the storage
*
* @param string $path
+ * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache
* @return \OC\Files\Cache\Cache
*/
- public function getCache($path = '');
+ public function getCache($path = '', $storage = null);
/**
* get a scanner instance for the storage
*
* @param string $path
+ * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
* @return \OC\Files\Cache\Scanner
*/
- public function getScanner($path = '');
+ public function getScanner($path = '', $storage = null);
/**
@@ -44,9 +46,10 @@ interface Storage extends \OCP\Files\Storage {
* get a watcher instance for the cache
*
* @param string $path
+ * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
* @return \OC\Files\Cache\Watcher
*/
- public function getWatcher($path = '');
+ public function getWatcher($path = '', $storage = null);
/**
* @return \OC\Files\Cache\Storage
diff --git a/lib/private/files/storage/wrapper/wrapper.php b/lib/private/files/storage/wrapper/wrapper.php
index 057c31c3cd8..d899c88363f 100644
--- a/lib/private/files/storage/wrapper/wrapper.php
+++ b/lib/private/files/storage/wrapper/wrapper.php
@@ -361,20 +361,28 @@ class Wrapper implements \OC\Files\Storage\Storage {
* get a cache instance for the storage
*
* @param string $path
+ * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache
* @return \OC\Files\Cache\Cache
*/
- public function getCache($path = '') {
- return $this->storage->getCache($path);
+ public function getCache($path = '', $storage = null) {
+ if (!$storage) {
+ $storage = $this;
+ }
+ return $this->storage->getCache($path, $storage);
}
/**
* get a scanner instance for the storage
*
* @param string $path
+ * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
* @return \OC\Files\Cache\Scanner
*/
- public function getScanner($path = '') {
- return $this->storage->getScanner($path);
+ public function getScanner($path = '', $storage = null) {
+ if (!$storage) {
+ $storage = $this;
+ }
+ return $this->storage->getScanner($path, $storage);
}
@@ -392,10 +400,14 @@ class Wrapper implements \OC\Files\Storage\Storage {
* get a watcher instance for the cache
*
* @param string $path
+ * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
* @return \OC\Files\Cache\Watcher
*/
- public function getWatcher($path = '') {
- return $this->storage->getWatcher($path);
+ public function getWatcher($path = '', $storage = null) {
+ if (!$storage) {
+ $storage = $this;
+ }
+ return $this->storage->getWatcher($path, $storage);
}
/**
@@ -417,6 +429,7 @@ class Wrapper implements \OC\Files\Storage\Storage {
/**
* Returns true
+ *
* @return true
*/
public function test() {
@@ -425,6 +438,7 @@ class Wrapper implements \OC\Files\Storage\Storage {
/**
* Returns the wrapped storage's value for isLocal()
+ *
* @return bool wrapped storage's isLocal() value
*/
public function isLocal() {
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index afccdf9f733..91d7ea260d3 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -161,7 +161,34 @@ class View {
return $this->basicOperation('mkdir', $path, array('create', 'write'));
}
+ protected function removeMount($mount, $path){
+ if ($mount instanceof MoveableMount) {
+ \OC_Hook::emit(
+ Filesystem::CLASSNAME, "umount",
+ array(Filesystem::signal_param_path => $path)
+ );
+ $result = $mount->removeMount();
+ if ($result) {
+ \OC_Hook::emit(
+ Filesystem::CLASSNAME, "post_umount",
+ array(Filesystem::signal_param_path => $path)
+ );
+ }
+ return $result;
+ } else {
+ // do not allow deleting the storage's root / the mount point
+ // because for some storages it might delete the whole contents
+ // but isn't supposed to work that way
+ return false;
+ }
+ }
+
public function rmdir($path) {
+ $absolutePath= $this->getAbsolutePath($path);
+ $mount = Filesystem::getMountManager()->find($absolutePath);
+ if ($mount->getInternalPath($absolutePath) === '') {
+ return $this->removeMount($mount, $path);
+ }
if ($this->is_dir($path)) {
return $this->basicOperation('rmdir', $path, array('delete'));
} else {
@@ -360,25 +387,7 @@ class View {
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
$mount = Filesystem::getMountManager()->find($absolutePath . $postFix);
if ($mount->getInternalPath($absolutePath) === '') {
- if ($mount instanceof MoveableMount) {
- \OC_Hook::emit(
- Filesystem::CLASSNAME, "umount",
- array(Filesystem::signal_param_path => $path)
- );
- $result = $mount->removeMount();
- if ($result) {
- \OC_Hook::emit(
- Filesystem::CLASSNAME, "post_umount",
- array(Filesystem::signal_param_path => $path)
- );
- }
- return $result;
- } else {
- // do not allow deleting the storage's root / the mount point
- // because for some storages it might delete the whole contents
- // but isn't supposed to work that way
- return false;
- }
+ return $this->removeMount($mount, $path);
}
return $this->basicOperation('unlink', $path, array('delete'));
}
@@ -836,11 +845,10 @@ class View {
return $data;
}
$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
- /**
- * @var \OC\Files\Storage\Storage $storage
- * @var string $internalPath
- */
- list($storage, $internalPath) = Filesystem::resolvePath($path);
+
+ $mount = Filesystem::getMountManager()->find($path);
+ $storage = $mount->getStorage();
+ $internalPath = $mount->getInternalPath($path);
$data = null;
if ($storage) {
$cache = $storage->getCache($internalPath);
@@ -888,6 +896,10 @@ class View {
return false;
}
+ if ($mount instanceof MoveableMount) {
+ $data['permissions'] |= \OCP\PERMISSION_DELETE | \OCP\PERMISSION_UPDATE;
+ }
+
$data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data);
return new FileInfo($path, $storage, $internalPath, $data);
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 3e2c1db79da..243baa46948 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -940,7 +940,7 @@ class OC_Helper {
// return storage info without adding mount points
$includeExtStorage = \OC_Config::getValue('quota_include_external_storage', false);
- if (is_null($rootInfo)) {
+ if (!$rootInfo) {
$rootInfo = \OC\Files\Filesystem::getFileInfo($path, false);
}
$used = $rootInfo->getSize();
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index a3de8ebc0ef..26108a937ce 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -508,9 +508,9 @@ class Share extends \OC\Share\Constants {
if ($itemType === 'folder') {
$path = '/' . $uidOwner . '/files' . \OC\Files\Filesystem::getPath($itemSource) . '/';
$mountManager = \OC\Files\Filesystem::getMountManager();
- $mounts = $mountManager->getAll();
- foreach ($mounts as $mountPoint => $mount) {
- if ($mount->getStorage() instanceof \OC\Files\Storage\Shared && strpos($mountPoint, $path) === 0) {
+ $mounts = $mountManager->findIn($path);
+ foreach ($mounts as $mount) {
+ if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) {
$message = 'Sharing "' . $itemSourceName . '" failed, because it contains files shared with you!';
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);