diff --git a/frontend/src/api/files.js b/frontend/src/api/files.js index 37d9fe72..cda31978 100644 --- a/frontend/src/api/files.js +++ b/frontend/src/api/files.js @@ -186,8 +186,11 @@ export async function unarchive(path, name, override) { return resourceAction(url, "PATCH"); } -export async function chmod(path, perms, recursive = false) { +export async function chmod(path, perms, recursive, recursionType) { const action = `chmod`; - const url = `${path}?action=${action}&permissions=${perms}&recursive=${recursive}`; + let url = `${path}?action=${action}&permissions=${perms}&recursive=${recursive}`; + if (recursive) { + url += `&type=${recursionType}`; + } return resourceAction(url, "PATCH"); } diff --git a/frontend/src/components/prompts/Permissions.vue b/frontend/src/components/prompts/Permissions.vue index aa34b2d5..e9ba4fb5 100644 --- a/frontend/src/components/prompts/Permissions.vue +++ b/frontend/src/components/prompts/Permissions.vue @@ -4,8 +4,8 @@
@@ -15,7 +15,7 @@ | |
{{ $t("prompts.owner") }} | @@ -27,7 +27,7 @@ |
{{ $t("prompts.group") }} | @@ -39,7 +39,7 @@ |
{{ $t("prompts.others") }} |
@@ -56,10 +56,50 @@
- - {{ $t("prompts.recursive") }} - + ++ + {{ $t("prompts.recursive") }}: + +
+
+
+ + + ++ + + ++ + + +
@@ -93,6 +133,7 @@ export default {
data: function () {
return {
recursive: false,
+ recursionType: "all",
permissions: {
owner: {
read: false,
@@ -191,7 +232,12 @@ export default {
try {
this.loading = true;
- await api.chmod(item.url, this.permMode, this.recursive);
+ await api.chmod(
+ item.url,
+ this.permMode,
+ this.recursive,
+ this.recursionType
+ );
this.$store.commit("setReload", true);
} catch (e) {
diff --git a/frontend/src/css/dashboard.css b/frontend/src/css/dashboard.css
index 558d8de7..6de01a01 100644
--- a/frontend/src/css/dashboard.css
+++ b/frontend/src/css/dashboard.css
@@ -461,4 +461,12 @@ table tr>*:last-child {
.card .card-action.full .action .title {
font-size: 1.5em;
font-weight: 500;
+}
+
+/* * * * * * * * * * * * * * * *
+ * PROMPT - PERMISSIONS *
+ * * * * * * * * * * * * * * * */
+
+#permissions .recursion-types {
+ padding-left: 1em;
}
\ No newline at end of file
diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json
index 7c32a0cc..42479afb 100644
--- a/frontend/src/i18n/en.json
+++ b/frontend/src/i18n/en.json
@@ -125,6 +125,9 @@
"group": "Group",
"others": "Others",
"recursive": "Recursive",
+ "directoriesAndFiles": "Directories and files",
+ "directories": "Directories",
+ "files": "Files",
"archive": "Archive",
"archiveMessage": "Choose archive name and format:",
"unarchive": "Unarchive",
diff --git a/http/resource.go b/http/resource.go
index e0ecf79c..5fc78a89 100644
--- a/http/resource.go
+++ b/http/resource.go
@@ -478,8 +478,9 @@ func parseArchiver(algo string) (string, archiver.Archiver, error) {
func chmodActionHandler(r *http.Request, d *data) error {
target := r.URL.Path
- recursive := r.URL.Query().Get("recursive") == "true"
perms := r.URL.Query().Get("permissions")
+ recursive := r.URL.Query().Get("recursive") == "true"
+ recursionType := r.URL.Query().Get("type")
if !d.user.Perm.Modify {
return errors.ErrPermissionDenied
@@ -500,13 +501,32 @@ func chmodActionHandler(r *http.Request, d *data) error {
}
if recursive && info.IsDir() {
+ var recFilter func(i os.FileInfo) bool
+
+ switch recursionType {
+ case "directories":
+ recFilter = func(i os.FileInfo) bool {
+ return i.IsDir()
+ }
+ case "files":
+ recFilter = func(i os.FileInfo) bool {
+ return !i.IsDir()
+ }
+ default:
+ recFilter = func(i os.FileInfo) bool {
+ return true
+ }
+ }
+
return afero.Walk(d.user.Fs, target, func(name string, info os.FileInfo, err error) error {
if err == nil {
- err = d.user.Fs.Chmod(name, os.FileMode(mode))
+ if recFilter(info) {
+ err = d.user.Fs.Chmod(name, os.FileMode(mode))
+ }
}
return err
})
- } else {
- return d.user.Fs.Chmod(target, os.FileMode(mode))
}
+
+ return d.user.Fs.Chmod(target, os.FileMode(mode))
}
|