From 67d00bc6bbcb2cbd39753c279f8449f593fa2f06 Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Fri, 11 Jan 2013 14:23:28 +0100 Subject: some more clean-up, isVersioned() is no longer needed; rename hook fixed if a complete folder gets renamed --- apps/files_versions/lib/hooks.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'apps/files_versions/lib/hooks.php') diff --git a/apps/files_versions/lib/hooks.php b/apps/files_versions/lib/hooks.php index 736d9cd8687..5fb9dc3c3c5 100644 --- a/apps/files_versions/lib/hooks.php +++ b/apps/files_versions/lib/hooks.php @@ -58,18 +58,16 @@ class Hooks { * of the stored versions along the actual file */ public static function rename_hook($params) { - $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)) { - $info=pathinfo($abs_newpath); - if(!file_exists($info['dirname'])) mkdir($info['dirname'], 0750, true); - $versions = Storage::getVersions($rel_oldpath); - foreach ($versions as $v) { - rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']); - } + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + + $versions = new Storage( new \OC_FilesystemView('') ); + + $oldpath = $params['oldpath']; + $newpath = $params['newpath']; + + if($oldpath<>'' && $newpath<>'') $versions->rename( $oldpath, $newpath ); + } } - + } -- cgit v1.2.3