summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib/hooks.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2012-07-09 16:07:26 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2012-07-11 11:06:29 +0200
commite248412ca9e9b75db5c7a4cc9651391e341c66f5 (patch)
treeaef16016bdade5ab0a5b995e0fc9a0fa364eedda /apps/files_versions/lib/hooks.php
parent0f0aa1827f446ca531732bb1c807c244ef66676a (diff)
downloadnextcloud-server-e248412ca9e9b75db5c7a4cc9651391e341c66f5.tar.gz
nextcloud-server-e248412ca9e9b75db5c7a4cc9651391e341c66f5.zip
use getStorage() to get versions location
update routine implemented version number of files_versions increased Conflicts: apps/files_versions/lib/hooks.php
Diffstat (limited to 'apps/files_versions/lib/hooks.php')
-rw-r--r--apps/files_versions/lib/hooks.php69
1 files changed, 37 insertions, 32 deletions
diff --git a/apps/files_versions/lib/hooks.php b/apps/files_versions/lib/hooks.php
index f93d4dabe22..bfc8fd3a378 100644
--- a/apps/files_versions/lib/hooks.php
+++ b/apps/files_versions/lib/hooks.php
@@ -30,41 +30,46 @@ class Hooks {
}
}
- /**
- * @brief Erase versions of deleted file
- * @param array
- *
- * This function is connected to the delete signal of OC_Filesystem
- * cleanup the versions directory if the actual file gets deleted
- */
+
+ /**
+ * @brief Erase versions of deleted file
+ * @param array
+ *
+ * This function is connected to the delete signal of OC_Filesystem
+ * cleanup the versions directory if the actual file gets deleted
+ */
public static function remove_hook($params) {
- $rel_path = $params['path'];
- $abs_path = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_path.'.v';
- if(Storage::isversioned($rel_path)) {
- $versions = Storage::getVersions($rel_path);
- foreach ($versions as $v){
- unlink($abs_path . $v['version']);
- }
- }
- }
-
- /**
- * @brief rename/move versions of renamed/moved files
- * @param array with oldpath and newpath
- *
- * This function is connected to the rename signal of OC_Filesystem and adjust the name and location
- * of the stored versions along the actual file
- */
+ $versions_fileview = \OCP\Files::getStorage('files_versions');
+ $rel_path = $params['path'];
+ $abs_path = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$rel_path.'.v';
+ if(Storage::isversioned($rel_path)) {
+ $versions = Storage::getVersions($rel_path);
+ foreach ($versions as $v){
+ unlink($abs_path . $v['version']);
+ }
+ }
+ }
+
+ /**
+ * @brief rename/move versions of renamed/moved files
+ * @param array with oldpath and newpath
+ *
+ * This function is connected to the rename signal of OC_Filesystem and adjust the name and location
+ * of the stored versions along the actual file
+ */
public static function rename_hook($params) {
- $rel_oldpath = $params['oldpath'];
- $abs_oldpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_oldpath.'.v';
- $abs_newpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$params['newpath'].'.v';
+ $versions_fileview = \OCP\Files::getStorage('files_versions');
+ $rel_oldpath = $params['oldpath'];
+ $abs_oldpath = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$rel_oldpath.'.v';
+ $abs_newpath = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$params['newpath'].'.v';
if(Storage::isversioned($rel_oldpath)) {
- $versions = Storage::getVersions($rel_oldpath);
- foreach ($versions as $v){
- rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);
- }
- }
+ $info=pathinfo($abs_newpath);
+ if(!file_exists($info['dirname'])) mkdir($info['dirname'],0700,true);
+ $versions = Storage::getVersions($rel_oldpath);
+ foreach ($versions as $v){
+ rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);
+ }
+ }
}
}