summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2016-02-08 16:13:57 +0100
committerArthur Schiwon <blizzz@owncloud.com>2016-02-08 16:33:49 +0100
commitb6e03fe2615686c40b55e7ceb2c65f5083439007 (patch)
tree5dd1b6144ab6b7023f339717d53d8c7889493081 /apps/files_versions
parent97b2e19c786e037acd99e31aabbf193c805617dd (diff)
downloadnextcloud-server-b6e03fe2615686c40b55e7ceb2c65f5083439007.tar.gz
nextcloud-server-b6e03fe2615686c40b55e7ceb2c65f5083439007.zip
versions provide more information when throwing hooks
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/lib/storage.php17
-rw-r--r--apps/files_versions/tests/versions.php4
2 files changed, 12 insertions, 9 deletions
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index 35b3110928b..ad17668e638 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -210,9 +210,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']));
+ \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path . $v['version'], 'trigger' => 'master file deleted'));
self::deleteVersion($view, $filename . '.v' . $v['version']);
- \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path . $v['version']));
+ \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path . $v['version'], 'trigger' => 'master file deleted'));
}
}
}
@@ -309,6 +309,7 @@ class Storage {
Storage::scheduleExpire($uid, $file);
\OC_Hook::emit('\OCP\Versions', 'rollback', array(
'path' => $filename,
+ 'revision' => $revision,
));
return true;
} else if ($versionCreated) {
@@ -444,9 +445,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']));
+ \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => 'retention constraint'));
self::deleteVersion($view, $version['path'] . '.v' . $version['version']);
- \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version']));
+ \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => 'retention constraint'));
}
}
}
@@ -705,9 +706,9 @@ class Storage {
}
foreach($toDelete as $key => $path) {
- \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path));
+ \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path, 'trigger' => 'versions quota exceeded'));
self::deleteVersion($versionsFileview, $path);
- \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path));
+ \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path, 'trigger' => 'versions quota exceeded'));
unset($allVersions[$key]); // update array with the versions we keep
\OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::DEBUG);
}
@@ -722,9 +723,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']));
+ \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => 'versions quota exceeded'));
self::deleteVersion($versionsFileview, $version['path'] . '.v' . $version['version']);
- \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version']));
+ \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => 'versions 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'];
diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php
index b85877cebd3..d7d9c7a4fb4 100644
--- a/apps/files_versions/tests/versions.php
+++ b/apps/files_versions/tests/versions.php
@@ -652,7 +652,9 @@ class Test_Files_Versioning extends \Test\TestCase {
'path' => '/sub/test.txt',
);
- $this->assertEquals($expectedParams, $params);
+ $this->assertEquals($expectedParams['path'], $params['path']);
+ $this->assertTrue(array_key_exists('revision', $params));
+ $this->assertTrue($params['revision'] > 0);
$this->assertEquals('version2', $this->rootView->file_get_contents($filePath));
$info2 = $this->rootView->getFileInfo($filePath);