]> source.dussan.org Git - nextcloud-server.git/commitdiff
also create root dir if it doesn't exist yet
authorBjoern Schiessle <schiessle@owncloud.com>
Wed, 14 Aug 2013 18:51:36 +0000 (20:51 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Sat, 17 Aug 2013 15:35:48 +0000 (17:35 +0200)
apps/files_versions/lib/versions.php

index 78971b6d90e6b0eff375f013e342f3939644b257..5e2414f2dceaa1c14ba3cbf3da5e47e000998037 100644 (file)
@@ -111,10 +111,11 @@ class Storage {
                        // create all parent folders
                        $dirname=  \OC_Filesystem::normalizePath(pathinfo($filename, PATHINFO_DIRNAME));
                        $dirParts = explode('/', $dirname);
+                       $dir = "/files_versions";
                        foreach ($dirParts as $part) {
                                $dir = $dir.'/'.$part;
-                               if(!$versions_view->file_exists($dir)) {
-                                       $versions_view->mkdir($dir);
+                               if(!$users_view->file_exists($dir)) {
+                                       $users_view->mkdir($dir);
                                }
                        }
 
@@ -185,13 +186,19 @@ class Storage {
 
                self::expire($newpath);
 
-               $abs_newpath = $versions_view->getLocalFile($newpath);
-
                if ( $files_view->is_dir($oldpath) && $versions_view->is_dir($oldpath) ) {
                        $versions_view->rename($oldpath, $newpath);
                } else  if ( ($versions = Storage::getVersions($uid, $oldpath)) ) {
-                       $info=pathinfo($abs_newpath);
-                       if(!file_exists($info['dirname'])) mkdir($info['dirname'], 0750, true);
+                       // create missing dirs if necessary
+                       $dirname = \OC_Filesystem::normalizePath(pathinfo($newpath, PATHINFO_DIRNAME));
+                       $dirParts = explode('/', $dirname);
+                       $dir = "/files_versions";
+                       foreach ($dirParts as $part) {
+                               $dir = $dir.'/'.$part;
+                               if(!$users_view->file_exists($dir)) {
+                                       $users_view->mkdir($dir);
+                               }
+                       }
                        foreach ($versions as $v) {
                                $versions_view->rename($oldpath.'.v'.$v['version'], $newpath.'.v'.$v['version']);
                        }