]> source.dussan.org Git - nextcloud-server.git/commitdiff
Propagate unencrypted_size up to the file cache root
authorVincent Petry <pvince81@owncloud.com>
Fri, 7 Mar 2014 10:00:22 +0000 (11:00 +0100)
committerVincent Petry <pvince81@owncloud.com>
Fri, 7 Mar 2014 10:00:22 +0000 (11:00 +0100)
lib/private/files/cache/homecache.php

index a7c310a3782f56b98a5f46894a71272ff087652a..2af5b03c6e148e90de27ce5cfaf489db555f30f3 100644 (file)
@@ -24,15 +24,20 @@ class HomeCache extends Cache {
                $entry = $this->get($path);
                if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
                        $id = $entry['fileid'];
-                       $sql = 'SELECT SUM(`size`) FROM `*PREFIX*filecache` ' .
+                       $sql = 'SELECT SUM(`size`) AS f1, ' .
+                          'SUM(`unencrypted_size`) AS f2 FROM `*PREFIX*filecache` ' .
                                'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0';
                        $result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
                        if ($row = $result->fetchRow()) {
-                               list($sum) = array_values($row);
+                               list($sum, $unencryptedSum) = array_values($row);
                                $totalSize = (int)$sum;
+                               $unencryptedSize = (int)$unencryptedSum;
                                if ($entry['size'] !== $totalSize) {
                                        $this->update($id, array('size' => $totalSize));
                                }
+                               if ($entry['unencrypted_size'] !== $unencryptedSize) {
+                                       $this->update($id, array('unencrypted_size' => $unencryptedSize));
+                               }
                        }
                }
                return $totalSize;