diff options
author | Morris Jobke <hey@morrisjobke.de> | 2014-07-13 18:14:14 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-07-13 18:14:14 +0200 |
commit | ec3224aab92e9227e652a97b1b7e317286ba5293 (patch) | |
tree | c6f02b564d54df1a028445d9b2ac6f7b6c21d363 /apps | |
parent | d7b8e3209be2e459cfb27d91af4a7aa58ce43662 (diff) | |
parent | aab33b8b0ef5ce690a830d3ed8e49c0ab8c1f1d1 (diff) | |
download | nextcloud-server-ec3224aab92e9227e652a97b1b7e317286ba5293.tar.gz nextcloud-server-ec3224aab92e9227e652a97b1b7e317286ba5293.zip |
Merge pull request #9563 from owncloud/version-delete-cache
Remove deleted versions from the cache
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_versions/lib/versions.php | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 5035defd60b..2e048416c11 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -132,6 +132,23 @@ class Storage { } /** + * delete the version from the storage and cache + * + * @param \OC\Files\View $view + * @param string $path + */ + protected static function deleteVersion($view, $path) { + $view->unlink($path); + /** + * @var \OC\Files\Storage\Storage $storage + * @var string $internalPath + */ + list($storage, $internalPath) = $view->resolvePath($path); + $cache = $storage->getCache($internalPath); + $cache->remove($internalPath); + } + + /** * Delete versions of a file */ public static function delete($path) { @@ -148,7 +165,7 @@ class Storage { if (!empty($versions)) { foreach ($versions as $v) { \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path . $v['version'])); - $view->unlink($filename . '.v' . $v['version']); + self::deleteVersion($view, $filename . '.v' . $v['version']); \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path . $v['version'])); } } @@ -219,7 +236,7 @@ class Storage { return true; }else if ( $versionCreated ) { - $users_view->unlink($version); + self::deleteVersion($users_view, $version); } } return false; @@ -471,7 +488,7 @@ class Storage { foreach($toDelete as $key => $path) { \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path)); - $versionsFileview->unlink($path); + self::deleteVersion($versionsFileview, $path); \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path)); unset($allVersions[$key]); // update array with the versions we keep \OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::DEBUG); @@ -485,7 +502,7 @@ class Storage { while ($availableSpace < 0 && $i < $numOfVersions) { $version = current($allVersions); \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'])); - $versionsFileview->unlink($version['path'].'.v'.$version['version']); + self::deleteVersion($versionsFileview, $version['path'] . '.v' . $version['version']); \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'])); \OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'].'.v'.$version['version'] , \OCP\Util::DEBUG); $versionsSize -= $version['size']; |