// Listen to write signals
OCP\Util::connectHook('OC_Filesystem', 'post_write', "OCA_Versions\Hooks", "write_hook");
// Listen to delete and rename signals
-OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA_Versions\Storage", "removeVersions");
-OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA_Versions\Storage", "renameVersions");
\ No newline at end of file
+OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA_Versions\Hooks", "remove_hook");
+OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA_Versions\Hooks", "rename_hook");
\ No newline at end of file
}
}
+ /**\r
+ * @brief Erase versions of deleted file\r
+ * @param array\r
+ *\r
+ * This function is connected to the delete signal of OC_Filesystem\r
+ * cleanup the versions directory if the actual file gets deleted\r
+ */\r
+ public static function remove_hook($params) {\r
+ $rel_path = $params['path'];\r
+ $abs_path = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_path.'.v';\r
+ if(Storage::isversioned($rel_path)) {\r
+ $versions = Storage::getVersions($rel_path);\r
+ foreach ($versions as $v){\r
+ unlink($abs_path . $v['version']);\r
+ }\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * @brief rename/move versions of renamed/moved files\r
+ * @param array with oldpath and newpath\r
+ *\r
+ * This function is connected to the rename signal of OC_Filesystem and adjust the name and location\r
+ * of the stored versions along the actual file\r
+ */\r
+ public static function rename_hook($params) {\r
+ $rel_oldpath = $params['oldpath'];\r
+ $abs_oldpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_oldpath.'.v';\r
+ $abs_newpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$params['newpath'].'.v';\r
+ if(Storage::isversioned($rel_oldpath)) {\r
+ $versions = Storage::getVersions($rel_oldpath);\r
+ foreach ($versions as $v){\r
+ rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);\r
+ }\r
+ }\r
+ }
+
}
?>
return $this->view->deleteAll( $dir, true );\r
\r
}\r
-\r
- /**\r
- * @brief Erase versions of deleted file\r
- * @param array\r
- * \r
- * This function is connected to the delete signal of OC_Filesystem\r
- * cleanup the versions directory if the actual file gets deleted\r
- */\r
- public static function removeVersions($params) {\r
- $rel_path = $params['path'];\r
- $abs_path = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_path.'.v';\r
- if(Storage::isversioned($rel_path)) {\r
- $versions = Storage::getVersions($rel_path);\r
- foreach ($versions as $v){\r
- unlink($abs_path . $v['version']);\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * @brief rename/move versions of renamed/moved files\r
- * @param array with oldpath and newpath\r
- * \r
- * This function is connected to the rename signal of OC_Filesystem and adjust the name and location\r
- * of the stored versions along the actual file\r
- */\r
- public static function renameVersions($params) {\r
- $rel_oldpath = $params['oldpath'];\r
- $abs_oldpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_oldpath.'.v';\r
- $abs_newpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$params['newpath'].'.v';\r
- if(Storage::isversioned($rel_oldpath)) {\r
- $versions = Storage::getVersions($rel_oldpath);\r
- foreach ($versions as $v){\r
- rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);\r
- }\r
- }\r
- }\r
}\r