aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-06-28 15:24:30 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-06-28 15:24:30 +0200
commitc4f5639cb40ebb7a7442ff259ee0ea4d83a8c8f2 (patch)
tree801bd3b4077c83d26fd4a816ef7cab700f6ddd79
parent3cea1b062e4e80245c75872589d2d7564ee3bca0 (diff)
parentbdd1baeb858b4968a6b69b48960abe3b9f63bc92 (diff)
downloadnextcloud-server-c4f5639cb40ebb7a7442ff259ee0ea4d83a8c8f2.tar.gz
nextcloud-server-c4f5639cb40ebb7a7442ff259ee0ea4d83a8c8f2.zip
Merge branch 'master' into calendar_export
-rw-r--r--apps/files_versions/ajax/getVersions.php2
-rw-r--r--apps/files_versions/appinfo/app.php3
-rw-r--r--apps/files_versions/versions.php37
3 files changed, 40 insertions, 2 deletions
diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php
index fe48434d2cb..f29d1760b6f 100644
--- a/apps/files_versions/ajax/getVersions.php
+++ b/apps/files_versions/ajax/getVersions.php
@@ -13,7 +13,7 @@ if( OCA_Versions\Storage::isversioned( $source ) ) {
$versionsFormatted = array();
foreach ( $versions AS $version ) {
- $versionsFormatted[] = OCP\Util::formatDate( doubleval($version) );
+ $versionsFormatted[] = OCP\Util::formatDate( $version['version'] );
}
$versionsSorted = array_reverse( $versions );
diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php
index bd06dc0ced3..105c5a102cb 100644
--- a/apps/files_versions/appinfo/app.php
+++ b/apps/files_versions/appinfo/app.php
@@ -9,3 +9,6 @@ OCP\Util::addscript('files_versions', 'versions');
// Listen to write signals
OCP\Util::connectHook('OC_Filesystem', 'post_write', "OCA_Versions\Storage", "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
diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php
index 9c0829ff1de..7ed5f257505 100644
--- a/apps/files_versions/versions.php
+++ b/apps/files_versions/versions.php
@@ -309,5 +309,40 @@ class Storage {
}
-
+ /**
+ * @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['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
+ */
+ public static function renameVersions($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';
+ if(Storage::isversioned($rel_oldpath)) {
+ $versions = Storage::getVersions($rel_oldpath);
+ foreach ($versions as $v){
+ rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);
+ }
+ }
+ }
}