]> source.dussan.org Git - nextcloud-server.git/commitdiff
create new version if the same file is uploaded again over the web interface
authorBjörn Schießle <schiessle@owncloud.com>
Thu, 14 Mar 2013 15:47:59 +0000 (16:47 +0100)
committerBjörn Schießle <schiessle@owncloud.com>
Thu, 14 Mar 2013 15:47:59 +0000 (16:47 +0100)
apps/files_versions/lib/versions.php

index 20611c61ec7a7b2ae9303279b6167a0798bd6534..8874fec6bd2f214534aca16da4e5dcef50904061 100644 (file)
@@ -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) ) {