diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-03-08 19:08:07 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-03-08 19:08:07 +0100 |
commit | 1d3beffacf70519d5d9c49b3a7af18faae99a6c4 (patch) | |
tree | f59a847c4fd34676b39adbfbb725b9415085dc97 /lib/files | |
parent | f9c24a0368876313205d988106b92ab052129b18 (diff) | |
download | nextcloud-server-1d3beffacf70519d5d9c49b3a7af18faae99a6c4.tar.gz nextcloud-server-1d3beffacf70519d5d9c49b3a7af18faae99a6c4.zip |
Cache: better rename hook for cache updater
Diffstat (limited to 'lib/files')
-rw-r--r-- | lib/files/cache/updater.php | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/lib/files/cache/updater.php b/lib/files/cache/updater.php index d04541c219f..e760ba71bc6 100644 --- a/lib/files/cache/updater.php +++ b/lib/files/cache/updater.php @@ -53,12 +53,36 @@ class Updater { } } + static public function renameUpdate($from, $to) { + /** + * @var \OC\Files\Storage\Storage $storageFrom + * @var \OC\Files\Storage\Storage $storageTo + * @var string $internalFrom + * @var string $internalTo + */ + list($storageFrom, $internalFrom) = self::resolvePath($from); + list($storageTo, $internalTo) = self::resolvePath($to); + if ($storageFrom && $storageTo) { + if ($storageFrom === $storageTo) { + $cache = $storageFrom->getCache($internalFrom); + $cache->move($internalFrom, $internalTo); + $cache->correctFolderSize($internalFrom); + $cache->correctFolderSize($internalTo); + self::correctFolder($from, time()); + self::correctFolder($to, time()); + } else { + self::deleteUpdate($from); + self::writeUpdate($to); + } + } + } + /** - * Update the mtime and ETag of all parent folders - * - * @param string $path - * @param string $time - */ + * Update the mtime and ETag of all parent folders + * + * @param string $path + * @param string $time + */ static public function correctFolder($path, $time) { if ($path !== '' && $path !== '/') { $parent = dirname($path); @@ -66,9 +90,9 @@ class Updater { $parent = ''; } /** - * @var \OC\Files\Storage\Storage $storage - * @var string $internalPath - */ + * @var \OC\Files\Storage\Storage $storage + * @var string $internalPath + */ list($storage, $internalPath) = self::resolvePath($parent); if ($storage) { $cache = $storage->getCache(); @@ -92,8 +116,7 @@ class Updater { * @param array $params */ static public function renameHook($params) { - self::deleteUpdate($params['oldpath']); - self::writeUpdate($params['newpath']); + self::renameUpdate($params['oldpath'], $params['newpath']); } /** |