mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-19 12:00:01 +01:00
Adds renaming.
This commit is contained in:
parent
35d85b4e99
commit
9a447a83bd
@ -247,6 +247,13 @@ var H5AI_CONFIG = {
|
||||
"size": 150
|
||||
},
|
||||
|
||||
/*
|
||||
Allow to rename files.
|
||||
*/
|
||||
"rename": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
/*
|
||||
Make entries selectable. At the moment only needed for packaged download and delete.
|
||||
*/
|
||||
|
@ -193,13 +193,40 @@ else if ($action === "delete") {
|
||||
}
|
||||
|
||||
if ($errors->size) {
|
||||
json_fail(1, "deletion failed for some");
|
||||
json_fail(2, "deletion failed for some");
|
||||
} else {
|
||||
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 {
|
||||
json_fail(100, "unsupported action");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user