]> source.dussan.org Git - nextcloud-server.git/commitdiff
Update etags in parent folders
authorMichael Gapczynski <mtgap@owncloud.com>
Mon, 31 Dec 2012 00:54:51 +0000 (19:54 -0500)
committerMichael Gapczynski <mtgap@owncloud.com>
Mon, 31 Dec 2012 00:54:51 +0000 (19:54 -0500)
lib/files/cache/updater.php

index fb9783023e8d911c0af5afd769c75ccb01a5d7d3..d57e4a1abe65f2a97e12d62cd9312dfd012893ba 100644 (file)
@@ -34,6 +34,7 @@ class Updater {
                $scanner = new Scanner($storage);
                $scanner->scan($internalPath, Scanner::SCAN_SHALLOW);
                $cache->correctFolderSize($internalPath);
+               self::eTagUpdate($path);
        }
 
        static public function deleteUpdate($path) {
@@ -45,6 +46,29 @@ class Updater {
                $cache = new Cache($storage);
                $cache->remove($internalPath);
                $cache->correctFolderSize($internalPath);
+               self::eTagUpdate($path);
+       }
+
+       static public function eTagUpdate($path) {
+               if ($path !== '') {
+                       $parent = dirname($path);
+                       if ($parent === '.') {
+                               $parent = '';
+                       }
+                       /**
+                       * @var \OC\Files\Storage\Storage $storage
+                       * @var string $internalPath
+                       */
+                       list($storage, $internalPath) = self::resolvePath($parent);
+                       if ($storage) {
+                               $cache = $storage->getCache();
+                               $id = $cache->getId($internalPath);
+                               if ($id !== -1) {
+                                       $cache->update($id, array('etag' => $storage->getETag($internalPath)));
+                                       self::updateFolderETags($parent);
+                               }
+                       }
+               }
        }
 
        /**