mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-06-08 10:32:23 -04:00
Adds renaming.
This commit is contained in:
parent
35d85b4e99
commit
9a447a83bd
2 changed files with 35 additions and 1 deletions
|
@ -247,6 +247,13 @@ var H5AI_CONFIG = {
|
||||||
"size": 150
|
"size": 150
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
Allow to rename files.
|
||||||
|
*/
|
||||||
|
"rename": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Make entries selectable. At the moment only needed for packaged download and delete.
|
Make entries selectable. At the moment only needed for packaged download and delete.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -193,13 +193,40 @@ else if ($action === "delete") {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($errors->size) {
|
if ($errors->size) {
|
||||||
json_fail(1, "deletion failed for some");
|
json_fail(2, "deletion failed for some");
|
||||||
} else {
|
} else {
|
||||||
json_exit();
|
json_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if ($action === "rename") {
|
||||||
|
|
||||||
|
json_fail(1, "renaming disabled", !$options["rename"]["enabled"]);
|
||||||
|
|
||||||
|
list($href, $name) = check_keys(array("href", "name"));
|
||||||
|
|
||||||
|
$d = H5ai::normalize_path(dirname($href), true);
|
||||||
|
$n = basename($href);
|
||||||
|
|
||||||
|
$code = $h5ai->getHttpCode($d);
|
||||||
|
if ($code == 401) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($code == "h5ai" && !$h5ai->is_ignored($n)) {
|
||||||
|
|
||||||
|
$absPath = $h5ai->getAbsPath($href);
|
||||||
|
$folder = H5ai::normalize_path(dirname($absPath));
|
||||||
|
|
||||||
|
if (!rename($absPath, $folder . "/" . $name)) {
|
||||||
|
json_fail(2, "renaming failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
json_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
else {
|
else {
|
||||||
json_fail(100, "unsupported action");
|
json_fail(100, "unsupported action");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue