added createMissingDirectories() method
This commit is contained in:
parent
a3d009e3b5
commit
f71794f0d5
|
@ -110,15 +110,7 @@ class Storage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create all parent folders
|
// create all parent folders
|
||||||
$dirname= \OC_Filesystem::normalizePath(pathinfo($filename, PATHINFO_DIRNAME));
|
self::createMissingDirectories($filename, $users_view);
|
||||||
$dirParts = explode('/', $dirname);
|
|
||||||
$dir = "/files_versions";
|
|
||||||
foreach ($dirParts as $part) {
|
|
||||||
$dir = $dir.'/'.$part;
|
|
||||||
if(!$users_view->file_exists($dir)) {
|
|
||||||
$users_view->mkdir($dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$versionsSize = self::getVersionsSize($uid);
|
$versionsSize = self::getVersionsSize($uid);
|
||||||
if ( $versionsSize === false || $versionsSize < 0 ) {
|
if ( $versionsSize === false || $versionsSize < 0 ) {
|
||||||
|
@ -191,15 +183,8 @@ class Storage {
|
||||||
$versions_view->rename($oldpath, $newpath);
|
$versions_view->rename($oldpath, $newpath);
|
||||||
} else if ( ($versions = Storage::getVersions($uid, $oldpath)) ) {
|
} else if ( ($versions = Storage::getVersions($uid, $oldpath)) ) {
|
||||||
// create missing dirs if necessary
|
// create missing dirs if necessary
|
||||||
$dirname = \OC_Filesystem::normalizePath(pathinfo($newpath, PATHINFO_DIRNAME));
|
self::createMissingDirectories($newpath, new \OC\Files\View('/'. $uidn));
|
||||||
$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) {
|
foreach ($versions as $v) {
|
||||||
$versions_view->rename($oldpath.'.v'.$v['version'], $newpath.'.v'.$v['version']);
|
$versions_view->rename($oldpath.'.v'.$v['version'], $newpath.'.v'.$v['version']);
|
||||||
}
|
}
|
||||||
|
@ -578,4 +563,20 @@ class Storage {
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief create recursively missing directories
|
||||||
|
* @param string $filename $path to a file
|
||||||
|
*/
|
||||||
|
private static function createMissingDirectories($filename, $view) {
|
||||||
|
$dirname = \OC_Filesystem::normalizePath(pathinfo($filename, PATHINFO_DIRNAME));
|
||||||
|
$dirParts = explode('/', $dirname);
|
||||||
|
$dir = "/files_versions";
|
||||||
|
foreach ($dirParts as $part) {
|
||||||
|
$dir = $dir . '/' . $part;
|
||||||
|
if (!$view->file_exists($dir)) {
|
||||||
|
$view->mkdir($dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue