diff options
Diffstat (limited to 'lib/private/Files')
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Quota.php | 22 | ||||
-rw-r--r-- | lib/private/Files/Stream/Encryption.php | 6 | ||||
-rw-r--r-- | lib/private/Files/View.php | 7 |
3 files changed, 22 insertions, 13 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php index 22338f9c3cc..a7d5f3101fe 100644 --- a/lib/private/Files/Storage/Wrapper/Quota.php +++ b/lib/private/Files/Storage/Wrapper/Quota.php @@ -46,7 +46,7 @@ class Quota extends Wrapper { * @param array $parameters */ public function __construct($parameters) { - $this->storage = $parameters['storage']; + parent::__construct($parameters); $this->quota = $parameters['quota']; $this->sizeRoot = isset($parameters['root']) ? $parameters['root'] : ''; } @@ -83,7 +83,7 @@ class Quota extends Wrapper { * @return int */ public function free_space($path) { - if ($this->quota < 0) { + if ($this->quota < 0 || strpos($path, 'cache') === 0) { return $this->storage->free_space($path); } else { $used = $this->getSize($this->sizeRoot); @@ -111,7 +111,7 @@ class Quota extends Wrapper { * @return bool */ public function file_put_contents($path, $data) { - $free = $this->free_space(''); + $free = $this->free_space($path); if ($free < 0 or strlen($data) < $free) { return $this->storage->file_put_contents($path, $data); } else { @@ -127,7 +127,7 @@ class Quota extends Wrapper { * @return bool */ public function copy($source, $target) { - $free = $this->free_space(''); + $free = $this->free_space($target); if ($free < 0 or $this->getSize($source) < $free) { return $this->storage->copy($source, $target); } else { @@ -147,7 +147,7 @@ class Quota extends Wrapper { // don't apply quota for part files if (!$this->isPartFile($path)) { - $free = $this->free_space(''); + $free = $this->free_space($path); if ($source && $free >= 0 && $mode !== 'r' && $mode !== 'rb') { // only apply quota for files, not metadata, trash or others if (strpos(ltrim($path, '/'), 'files/') === 0) { @@ -178,7 +178,7 @@ class Quota extends Wrapper { * @return bool */ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { - $free = $this->free_space(''); + $free = $this->free_space($targetInternalPath); if ($free < 0 or $this->getSize($sourceInternalPath, $sourceStorage) < $free) { return $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } else { @@ -193,11 +193,19 @@ class Quota extends Wrapper { * @return bool */ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { - $free = $this->free_space(''); + $free = $this->free_space($targetInternalPath); if ($free < 0 or $this->getSize($sourceInternalPath, $sourceStorage) < $free) { return $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } else { return false; } } + + public function mkdir($path) { + if ($this->quota === 0.0) { + return false; + } + + return parent::mkdir($path); + } } diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php index 05be5a5b286..65d379c0289 100644 --- a/lib/private/Files/Stream/Encryption.php +++ b/lib/private/Files/Stream/Encryption.php @@ -195,10 +195,10 @@ class Encryption extends Wrapper { protected static function wrapSource($source, $context, $protocol, $class, $mode = 'r+') { try { stream_wrapper_register($protocol, $class); - if (@rewinddir($source) === false) { - $wrapped = fopen($protocol . '://', $mode, false, $context); - } else { + if (self::isDirectoryHandle($source)) { $wrapped = opendir($protocol . '://', $context); + } else { + $wrapped = fopen($protocol . '://', $mode, false, $context); } } catch (\BadMethodCallException $e) { stream_wrapper_unregister($protocol); diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index a149cdf0af5..527ca728229 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1316,15 +1316,13 @@ class View { try { // if the file is not in the cache or needs to be updated, trigger the scanner and reload the data if (!$data || $data['size'] === -1) { - $this->lockFile($relativePath, ILockingProvider::LOCK_SHARED); if (!$storage->file_exists($internalPath)) { - $this->unlockFile($relativePath, ILockingProvider::LOCK_SHARED); return false; } + // don't need to get a lock here since the scanner does it's own locking $scanner = $storage->getScanner($internalPath); $scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW); $data = $cache->get($internalPath); - $this->unlockFile($relativePath, ILockingProvider::LOCK_SHARED); } else if (!Cache\Scanner::isPartialFile($internalPath) && $watcher->needsUpdate($internalPath, $data)) { $this->lockFile($relativePath, ILockingProvider::LOCK_SHARED); $watcher->update($internalPath, $data); @@ -1361,6 +1359,7 @@ class View { $mount = Filesystem::getMountManager()->find($path); if (!$mount) { + \OC::$server->getLogger()->warning('Mountpoint not found for path: ' . $path); return false; } $storage = $mount->getStorage(); @@ -1392,6 +1391,8 @@ class View { } return $info; + } else { + \OC::$server->getLogger()->warning('Storage not valid for mountpoint: ' . $mount->getMountPoint()); } return false; |