Permalink
Browse files

Mkdir recursive

Recycle restore : recreate parent folder if it was removed before restoration.
  • Loading branch information...
1 parent 8484f21 commit 9271af6af26fc952a5ceb70b551fbe6ec6948087 @cdujeu cdujeu committed Sep 3, 2016
@@ -1003,6 +1003,9 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
if($selection->isUnique() && isSet($httpVars["targetBaseName"])){
$targetBaseName = $httpVars["targetBaseName"];
}
+ if(!file_exists($destPath) && isSet($httpVars["recycle_restore"])){
+ $this->mkDir($selection->nodeForPath(dirname($destPath)), basename($destPath), false, true);
+ }
$this->filterUserSelectionToHidden($ctx, [$httpVars["dest"]]);
if ($selection->inZip()) {
// Set action to copy anycase (cannot move from the zip).
@@ -1127,7 +1130,12 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
continue;
}
try{
- $newNode = $this->mkDir($parentNode, $basename, isSet($httpVars["ignore_exists"])?true:false);
+ $newNode = $this->mkDir(
+ $parentNode,
+ $basename,
+ (isSet($httpVars["ignore_exists"]) && $httpVars["ignore_exists"] === "true"),
+ (isSet($httpVars["recursive"]) && $httpVars["recursive"] === "true")
+ );
}catch(PydioException $ex){
$errors[] = $ex->getMessage();
continue;
@@ -2099,11 +2107,16 @@ public static function autoRenameForDest($destination, $fileName)
* @param AJXP_Node $parentNode
* @param String $newDirName
* @param bool $ignoreExists
+ * @param bool $createRecursive
* @return AJXP_Node
+ * @throws PydioException
* @throws \Exception
*/
- public function mkDir($parentNode, $newDirName, $ignoreExists = false)
+ public function mkDir($parentNode, $newDirName, $ignoreExists = false, $createRecursive = false)
{
+ if(!file_exists($parentNode->getUrl()) && $createRecursive){
+ $this->mkDir($parentNode->getParent(), basename($parentNode->getUrl()), $ignoreExists, true);
+ }
Controller::applyHook("node.before_change", [&$parentNode]);
$mess = LocaleService::getMessages();
@@ -45,8 +45,11 @@ public function getResourceUrl($path);
* Creates a directory
* @param String $path
* @param String $newDirName
+ * @param bool $ignoreExists
+ * @param bool $recursive
+ * @return
*/
- public function mkDir($path, $newDirName);
+ public function mkDir($path, $newDirName, $ignoreExists=false, $recursive=false);
/**
* Creates an empty file
@@ -107,6 +107,7 @@ public static function filterActions(&$action, $selection, &$httpVars)
$originalRep = self::getFileOrigin($selection->getUniqueFile());
if ($originalRep != "") {
$action = "move";
+ $httpVars["recycle_restore"] = true;
$httpVars["dest"] = $originalRep; // CHECK UTF8 HANDLING HERE
}
}

0 comments on commit 9271af6

Please sign in to comment.