From 0cf50d63bfcbe359d850a7ce0228555a3766b31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Thu, 14 Mar 2013 16:47:59 +0100 Subject: [PATCH 1/3] create new version if the same file is uploaded again over the web interface --- apps/files_versions/lib/versions.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 20611c61ec7..8874fec6bd2 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -156,11 +156,18 @@ class Storage { /** * rename versions of a file */ - public static function rename($oldpath, $newpath) { - list($uid, $oldpath) = self::getUidAndFilename($oldpath); - list($uidn, $newpath) = self::getUidAndFilename($newpath); + public static function rename($old_path, $new_path) { + list($uid, $oldpath) = self::getUidAndFilename($old_path); + list($uidn, $newpath) = self::getUidAndFilename($new_path); $versions_view = new \OC\Files\View('/'.$uid .'/files_versions'); $files_view = new \OC\Files\View('/'.$uid .'/files'); + + // if the file already exists than it was a upload of a existing file + // over the web interface -> store() is the right function we need here + if ($files_view->file_exists($newpath)) { + return self::store($newpath); + } + $abs_newpath = $versions_view->getLocalFile($newpath); if ( $files_view->is_dir($oldpath) && $versions_view->is_dir($oldpath) ) { From 93b2ada6f6b54dc9b3c341c379e524f51a75b8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Thu, 14 Mar 2013 17:08:16 +0100 Subject: [PATCH 2/3] fix var name --- apps/files_versions/lib/versions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 8874fec6bd2..6d47b3038c6 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -164,7 +164,7 @@ class Storage { // if the file already exists than it was a upload of a existing file // over the web interface -> store() is the right function we need here - if ($files_view->file_exists($newpath)) { + if ($files_view->file_exists($new_path)) { return self::store($newpath); } From f78594c0aeeb29bfc4365f48dbb967b645fd5c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Thu, 14 Mar 2013 17:09:48 +0100 Subject: [PATCH 3/3] fix var name --- apps/files_versions/lib/versions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 6d47b3038c6..f99e26a0915 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -164,8 +164,8 @@ class Storage { // if the file already exists than it was a upload of a existing file // over the web interface -> store() is the right function we need here - if ($files_view->file_exists($new_path)) { - return self::store($newpath); + if ($files_view->file_exists($newpath)) { + return self::store($new_path); } $abs_newpath = $versions_view->getLocalFile($newpath);