aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/files
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/files')
-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
6 files changed, 92 insertions, 48 deletions
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);