summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2016-02-08 18:16:27 +0100
committerArthur Schiwon <blizzz@owncloud.com>2016-02-08 18:16:27 +0100
commitd2d664470216193785300ccf99adc4478f776a88 (patch)
treeb9b7019adccf4ad7e66ab8c56cd7ed2e20b8ca91 /apps/files_versions
parentb6e03fe2615686c40b55e7ceb2c65f5083439007 (diff)
downloadnextcloud-server-d2d664470216193785300ccf99adc4478f776a88.tar.gz
nextcloud-server-d2d664470216193785300ccf99adc4478f776a88.zip
use int values and constants instead of strings
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/lib/storage.php20
1 files changed, 12 insertions, 8 deletions
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index ad17668e638..88a4126dabd 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -52,6 +52,10 @@ class Storage {
const DEFAULTMAXSIZE=50; // unit: percentage; 50% of available disk space/quota
const VERSIONS_ROOT = 'files_versions/';
+ const DELETE_TRIGGER_MASTER_REMOVED = 0;
+ const DELETE_TRIGGER_RETENTION_CONSTRAINT = 1;
+ const DELETE_TRIGGER_QUOTA_EXCEEDED = 2;
+
// files for which we can remove the versions after the delete operation was successful
private static $deletedFiles = array();
@@ -210,9 +214,9 @@ class Storage {
$versions = self::getVersions($uid, $filename);
if (!empty($versions)) {
foreach ($versions as $v) {
- \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path . $v['version'], 'trigger' => 'master file deleted'));
+ \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path . $v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED));
self::deleteVersion($view, $filename . '.v' . $v['version']);
- \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path . $v['version'], 'trigger' => 'master file deleted'));
+ \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path . $v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED));
}
}
}
@@ -445,9 +449,9 @@ class Storage {
$view = new \OC\Files\View('/' . $uid . '/files_versions');
if (!empty($toDelete)) {
foreach ($toDelete as $version) {
- \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => 'retention constraint'));
+ \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT));
self::deleteVersion($view, $version['path'] . '.v' . $version['version']);
- \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => 'retention constraint'));
+ \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT));
}
}
}
@@ -706,9 +710,9 @@ class Storage {
}
foreach($toDelete as $key => $path) {
- \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path, 'trigger' => 'versions quota exceeded'));
+ \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
self::deleteVersion($versionsFileview, $path);
- \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path, 'trigger' => 'versions quota exceeded'));
+ \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
unset($allVersions[$key]); // update array with the versions we keep
\OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::DEBUG);
}
@@ -723,9 +727,9 @@ class Storage {
reset($allVersions);
while ($availableSpace < 0 && $i < $numOfVersions) {
$version = current($allVersions);
- \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => 'versions quota exceeded'));
+ \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
self::deleteVersion($versionsFileview, $version['path'] . '.v' . $version['version']);
- \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => 'versions quota exceeded'));
+ \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED));
\OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'].'.v'.$version['version'] , \OCP\Util::DEBUG);
$versionsSize -= $version['size'];
$availableSpace += $version['size'];