Merge pull request #5822 from owncloud/delete_hooks_trash_and_versions

Implement delete hooks for trashbin and filesversions apps.
This commit is contained in:
Morris Jobke 2013-11-12 07:03:37 -08:00
commit dc30056025
3 changed files with 6 additions and 0 deletions

View File

@ -530,6 +530,7 @@ class Trashbin {
$size += $view->filesize('/files_trashbin/files/' . $file);
}
$view->unlink('/files_trashbin/files/' . $file);
\OC_Hook::emit('\OCP\Trashbin', 'delete', array('path' => '/files_trashbin/files/' . $file));
$trashbinSize -= $size;
self::setTrashbinSize($user, $trashbinSize);

View File

@ -156,6 +156,7 @@ class Storage {
}
foreach ($versions as $v) {
unlink($abs_path . $v['version']);
\OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $abs_path . $v['version']));
$versionsSize -= $v['size'];
}
self::setVersionsSize($uid, $versionsSize);
@ -465,6 +466,7 @@ class Storage {
while ($availableSpace < 0 && $i < $numOfVersions) {
$version = current($allVersions);
$versionsFileview->unlink($version['path'].'.v'.$version['version']);
\OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version']));
$versionsSize -= $version['size'];
$availableSpace += $version['size'];
next($allVersions);
@ -515,6 +517,7 @@ class Storage {
if ($version['version'] > $nextVersion) {
//distance between two version too small, delete version
$versionsFileview->unlink($version['path'] . '.v' . $version['version']);
\OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'] . '.v' . $version['version']));
$size += $version['size'];
unset($allVersions[$key]); // update array with all versions
} else {

View File

@ -619,6 +619,8 @@ class OC {
public static function registerPreviewHooks() {
OC_Hook::connect('OC_Filesystem', 'post_write', 'OC\Preview', 'post_write');
OC_Hook::connect('OC_Filesystem', 'delete', 'OC\Preview', 'post_delete');
OC_Hook::connect('\OCP\Versions', 'delete', 'OC\Preview', 'post_delete');
OC_Hook::connect('\OCP\Trashbin', 'delete', 'OC\Preview', 'post_delete');
}
/**