summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-03-23 13:07:40 +0100
committerRobin Appelman <icewind@owncloud.com>2015-03-26 17:07:01 +0100
commit7ec8f12ad4f8d05f540c02145eab641f69f8dc04 (patch)
tree9140061f0399a54fa6a73c81c6d762656d657591 /apps/files_versions/lib
parent39dbf9509b1aa3988a14cb62402c437171dc213e (diff)
downloadnextcloud-server-7ec8f12ad4f8d05f540c02145eab641f69f8dc04.tar.gz
nextcloud-server-7ec8f12ad4f8d05f540c02145eab641f69f8dc04.zip
expire versions in a background command
Diffstat (limited to 'apps/files_versions/lib')
-rw-r--r--apps/files_versions/lib/storage.php27
1 files changed, 22 insertions, 5 deletions
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index 60a4c463fd5..40f6ad7e77d 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -15,6 +15,8 @@
namespace OCA\Files_Versions;
+use OCA\Files_Versions\Command\Expire;
+
class Storage {
const DEFAULTENABLED=true;
@@ -132,7 +134,7 @@ class Storage {
// 1.5 times as large as the current version -> 2.5
$neededSpace = $files_view->filesize($filename) * 2.5;
- self::expire($filename, $versionsSize, $neededSpace);
+ self::scheduleExpire($filename, $versionsSize, $neededSpace);
// disable proxy to prevent multiple fopen calls
$proxyStatus = \OC_FileProxy::$enabled;
@@ -237,7 +239,7 @@ class Storage {
}
if (!$files_view->is_dir($newpath)) {
- self::expire($newpath);
+ self::scheduleExpire($newpath);
}
}
@@ -272,7 +274,7 @@ class Storage {
// rollback
if( @$users_view->rename('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) {
$files_view->touch($file, $revision);
- Storage::expire($file);
+ Storage::scheduleExpire($file);
return true;
}else if ( $versionCreated ) {
@@ -476,9 +478,24 @@ class Storage {
}
/**
- * Erase a file's versions which exceed the set quota
+ * @param string $fileName
+ * @param int|null $versionsSize
+ * @param int $neededSpace
+ */
+ private static function scheduleExpire($fileName, $versionsSize = null, $neededSpace = 0) {
+ $command = new Expire($fileName, $versionsSize, $neededSpace);
+ \OC::$server->getCommandBus()->push($command);
+ }
+
+ /**
+ * Expire versions which exceed the quota
+ *
+ * @param $filename
+ * @param int|null $versionsSize
+ * @param int $offset
+ * @return bool|int|null
*/
- private static function expire($filename, $versionsSize = null, $offset = 0) {
+ public static function expire($filename, $versionsSize = null, $offset = 0) {
$config = \OC::$server->getConfig();
if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);