]> source.dussan.org Git - nextcloud-server.git/commitdiff
backport file cache changes from master to stable5, needed for encryption app
authorBjörn Schießle <schiessle@owncloud.com>
Fri, 24 May 2013 11:40:37 +0000 (13:40 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Fri, 24 May 2013 11:40:37 +0000 (13:40 +0200)
db_structure.xml
lib/files/cache/cache.php
lib/files/cache/scanner.php
lib/files/view.php

index 81bdb8764937394cabb1e0d61a338157bf5c2a31..3d9159eb01986874f13076519df7406fea72bb37 100644 (file)
                                <length>4</length>
                        </field>
 
+                       <field>
+                <name>unencrypted_size</name>
+                <type>integer</type>
+                <default></default>
+                <notnull>true</notnull>
+                <length>8</length>
+            </field>
+
                        <field>
                                <name>etag</name>
                                <type>text</type>
index d30c5cd16edaa70ba3fdc082b3062617b9846b2f..1d73cb9c7616ac64523e9d3e8db1d66b7b3c950b 100644 (file)
@@ -117,7 +117,7 @@ class Cache {
                        $params = array($file);
                }
                $query = \OC_DB::prepare(
-                       'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `etag`
+                       'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `unencrypted_size`, `etag`
                         FROM `*PREFIX*filecache` ' . $where);
                $result = $query->execute($params);
                $data = $result->fetchRow();
@@ -133,6 +133,7 @@ class Cache {
                        $data['size'] = (int)$data['size'];
                        $data['mtime'] = (int)$data['mtime'];
                        $data['encrypted'] = (bool)$data['encrypted'];
+                       $data['unencrypted_size'] = (int)$data['unencrypted_size'];
                        $data['storage'] = $this->storageId;
                        $data['mimetype'] = $this->getMimetype($data['mimetype']);
                        $data['mimepart'] = $this->getMimetype($data['mimepart']);
@@ -151,7 +152,7 @@ class Cache {
                $fileId = $this->getId($folder);
                if ($fileId > -1) {
                        $query = \OC_DB::prepare(
-                               'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `etag`
+                               'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `unencrypted_size` , `etag`
                                 FROM `*PREFIX*filecache` WHERE parent = ? ORDER BY `name` ASC');
                        $result = $query->execute(array($fileId));
                        $files = $result->fetchAll();
@@ -234,7 +235,7 @@ class Cache {
         * @return array
         */
        function buildParts(array $data) {
-               $fields = array('path', 'parent', 'name', 'mimetype', 'size', 'mtime', 'encrypted', 'etag');
+               $fields = array('path', 'parent', 'name', 'mimetype', 'size', 'mtime', 'encrypted', 'unencrypted_size', 'etag');
                $params = array();
                $queryParts = array();
                foreach ($data as $name => $value) {
@@ -394,7 +395,7 @@ class Cache {
         */
        public function search($pattern) {
                $query = \OC_DB::prepare('
-                       SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `etag`
+                       SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `unencrypted_size`, `etag`
                        FROM `*PREFIX*filecache` WHERE `name` LIKE ? AND `storage` = ?'
                );
                $result = $query->execute(array($pattern, $this->numericId));
@@ -420,7 +421,7 @@ class Cache {
                        $where = '`mimepart` = ?';
                }
                $query = \OC_DB::prepare('
-                       SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `etag`
+                       SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `unencrypted_size`, `etag`
                        FROM `*PREFIX*filecache` WHERE ' . $where . ' AND `storage` = ?'
                );
                $mimetype = $this->getMimetypeId($mimetype);
@@ -443,7 +444,7 @@ class Cache {
                $this->calculateFolderSize($path);
                if ($path !== '') {
                        $parent = dirname($path);
-                       if ($parent === '.') {
+                       if ($parent === '.' or $parent === '/') {
                                $parent = '';
                        }
                        $this->correctFolderSize($parent);
index 594483e8be0704d82001ce10b7ef30cd82381a3d..0b1947f17cac7c121d89bb2274b1d6076084a5b9 100644 (file)
@@ -70,7 +70,7 @@ class Scanner {
                        if ($data) {
                                if ($file) {
                                        $parent = dirname($file);
-                                       if ($parent === '.') {
+                                       if ($parent === '.' or $parent === '/') {
                                                $parent = '';
                                        }
                                        if (!$this->cache->inCache($parent)) {
index 8c3f6bf6a19ed5a86cd98658be7906784b6ca3e1..61088cd2ca05d4d49b329f56cbbdaddb5bd84905 100644 (file)
@@ -755,6 +755,9 @@ class View {
                                $data['permissions'] = $permissions;
                        }
                }
+
+               $data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data);
+
                return $data;
        }