Skip to content

Commit

Permalink
Merge pull request #2317 from owncloud/create_version_on_upload
Browse files Browse the repository at this point in the history
create new version if the same file is uploaded again over the web interface
  • Loading branch information
Frank Karlitschek committed Mar 15, 2013
2 parents 0c123eb + f78594c commit 92a8676
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions apps/files_versions/lib/versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,18 @@ public static function delete($filename) {
/**
* 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($new_path);
}

$abs_newpath = $versions_view->getLocalFile($newpath);

if ( $files_view->is_dir($oldpath) && $versions_view->is_dir($oldpath) ) {
Expand Down

0 comments on commit 92a8676

Please sign in to comment.