Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/files
diff options
context:
space:
mode:
Diffstat (limited to 'lib/files')
-rw-r--r--lib/files/cache/cache.php2
-rw-r--r--lib/files/cache/legacy.php6
-rw-r--r--lib/files/cache/scanner.php31
-rw-r--r--lib/files/filesystem.php4
-rw-r--r--lib/files/storage/local.php2
-rw-r--r--lib/files/storage/temporary.php1
6 files changed, 31 insertions, 15 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index dcb6e8fd39a..38b35c69def 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -56,7 +56,7 @@ class Cache {
} else {
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*storages`(`id`) VALUES(?)');
$query->execute(array($this->storageId));
- $this->numericId = \OC_DB::insertid('*PREFIX*filecache');
+ $this->numericId = \OC_DB::insertid('*PREFIX*storages');
}
}
diff --git a/lib/files/cache/legacy.php b/lib/files/cache/legacy.php
index 33d4b8e7c9f..6d1ffa7b40b 100644
--- a/lib/files/cache/legacy.php
+++ b/lib/files/cache/legacy.php
@@ -51,6 +51,12 @@ class Legacy {
$this->cacheHasItems = false;
return false;
}
+
+ if ($result === false || property_exists($result, 'error_message_prefix')) {
+ $this->cacheHasItems = false;
+ return false;
+ }
+
$this->cacheHasItems = (bool)$result->fetchRow();
return $this->cacheHasItems;
}
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php
index 5a9a119458e..88f208547f6 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -58,9 +58,10 @@ class Scanner {
* scan a single file and store it in the cache
*
* @param string $file
+ * @param bool $checkExisting check existing folder sizes in the cache instead of always using -1 for folder size
* @return array with metadata of the scanned file
*/
- public function scanFile($file) {
+ public function scanFile($file, $checkExisting = false) {
\OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId));
$data = $this->getData($file);
if ($data) {
@@ -73,7 +74,15 @@ class Scanner {
$this->scanFile($parent);
}
}
- $id = $this->cache->put($file, $data);
+ if ($checkExisting and $cacheData = $this->cache->get($file)) {
+ if ($data['size'] === -1) {
+ $data['size'] = $cacheData['size'];
+ }
+ if ($data['mtime'] === $cacheData['mtime']) {
+ $data['etag'] = $cacheData['etag'];
+ }
+ }
+ $this->cache->put($file, $data);
}
return $data;
}
@@ -99,20 +108,18 @@ class Scanner {
while ($file = readdir($dh)) {
if (!$this->isIgnoredFile($file)) {
$child = ($path) ? $path . '/' . $file : $file;
- $data = $this->scanFile($child);
+ $data = $this->scanFile($child, $recursive === self::SCAN_SHALLOW);
if ($data) {
- if ($data['mimetype'] === 'httpd/unix-directory') {
+ if ($data['size'] === -1) {
if ($recursive === self::SCAN_RECURSIVE) {
$childQueue[] = $child;
$data['size'] = 0;
} else {
- $data['size'] = -1;
+ $size = -1;
}
- } else {
}
- if ($data['size'] === -1) {
- $size = -1;
- } elseif ($size !== -1) {
+
+ if ($size !== -1) {
$size += $data['size'];
}
}
@@ -133,7 +140,7 @@ class Scanner {
}
return $size;
}
-
+
/**
* @brief check if the file should be ignored when scanning
* NOTE: files with a '.part' extension are ignored as well!
@@ -143,8 +150,8 @@ class Scanner {
*/
private function isIgnoredFile($file) {
if ($file === '.' || $file === '..'
- || pathinfo($file,PATHINFO_EXTENSION) === 'part')
- {
+ || pathinfo($file, PATHINFO_EXTENSION) === 'part'
+ ) {
return true;
}
return false;
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index 71bf3d8708d..a0c3c4b9b75 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -190,14 +190,14 @@ class Filesystem {
}
}
- static public function init($root) {
+ static public function init($user, $root) {
if (self::$defaultInstance) {
return false;
}
self::$defaultInstance = new View($root);
//load custom mount config
- self::initMountPoints();
+ self::initMountPoints($user);
self::$loaded = true;
diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php
index 038d68bf46b..aaa3c0fab49 100644
--- a/lib/files/storage/local.php
+++ b/lib/files/storage/local.php
@@ -25,6 +25,8 @@ class Local extends \OC\Files\Storage\Common{
$this->datadir.='/';
}
}
+ public function __destruct() {
+ }
public function getId(){
return 'local::'.$this->datadir;
}
diff --git a/lib/files/storage/temporary.php b/lib/files/storage/temporary.php
index 542d2cd9f48..d84dbda2e39 100644
--- a/lib/files/storage/temporary.php
+++ b/lib/files/storage/temporary.php
@@ -21,6 +21,7 @@ class Temporary extends Local{
}
public function __destruct() {
+ parent::__destruct();
$this->cleanUp();
}
}