summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/versions.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2012-06-28 14:06:20 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2012-06-28 14:06:20 +0200
commite5792cc064c41c2a5bca32b886a8bc08cce2fb3f (patch)
tree96d6252db48ea9dbd8c96e1fff6c7d6c5792a12d /apps/files_versions/versions.php
parentf22f49671bcdc87058c6060db4ca4e4e1d9704f1 (diff)
downloadnextcloud-server-e5792cc064c41c2a5bca32b886a8bc08cce2fb3f.tar.gz
nextcloud-server-e5792cc064c41c2a5bca32b886a8bc08cce2fb3f.zip
adjust the name and/or location of the stored versions if the actual file gets moved or renamed
Diffstat (limited to 'apps/files_versions/versions.php')
-rw-r--r--apps/files_versions/versions.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php
index 787de0f78ad..b733c57923e 100644
--- a/apps/files_versions/versions.php
+++ b/apps/files_versions/versions.php
@@ -310,7 +310,11 @@ class Storage {
}
/**
- * @brief Erase versions of deleted file
+ * @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 removeVersions($params) {
$rel_path = $params[\OC_Filesystem::signal_param_path];
@@ -322,4 +326,23 @@ class Storage {
}
}
}
+
+ /**
+ * @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 renameVersions($params) {
+ $rel_oldpath = $params['oldpath'];
+ $abs_oldpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser()."/versions".$rel_oldpath.'.v';
+ $abs_newpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser()."/versions".$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']);
+ }
+ }
+ }
}