Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Mkdir recursive
Browse files Browse the repository at this point in the history
Recycle restore : recreate parent folder if it was removed before restoration.
  • Loading branch information
cdujeu committed Sep 3, 2016
1 parent 8484f21 commit 9271af6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
17 changes: 15 additions & 2 deletions core/src/plugins/access.fs/FsAccessDriver.php
Expand Up @@ -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).
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion core/src/plugins/core.access/src/IAjxpWrapperProvider.php
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/core.access/src/RecycleBinManager.php
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 9271af6

Please sign in to comment.