🔒️ Require FILES_DELETE permission to overwrite a file
This commit is contained in:
1 parent
452dcdfbcc
commit
3092734c62
2 files changed
+26
-11
No files matched your search
@@ -607,6 +607,15 @@ def uploadGcodeFile(target):
|
||||
):
|
||||
abort(409, description="File already exists and noOverwrite was set")
|
||||
|
||||
if (
|
||||
fileManager.file_exists(FileDestinations.LOCAL, futureFullPathInStorage)
|
||||
and not Permissions.FILES_DELETE.can()
|
||||
):
|
||||
abort(
|
||||
403,
|
||||
description="File already exists, cannot overwrite due to a lack of permissions",
|
||||
)
|
||||
|
||||
reselect = printer.is_current_file(futureFullPathInStorage, sd)
|
||||
|
||||
user = current_user.get_name()
|
||||
|
||||
@@ -1600,9 +1600,7 @@ $(function () {
|
||||
name: file.name
|
||||
})
|
||||
);
|
||||
$("input", self.uploadExistsDialog)
|
||||
.val("")
|
||||
.prop("placeholder", response.suggestion);
|
||||
$("input", self.uploadExistsDialog).val(response.suggestion);
|
||||
$("a.upload-rename", self.uploadExistsDialog)
|
||||
.prop("disabled", false)
|
||||
.off("click")
|
||||
@@ -1611,7 +1609,6 @@ $(function () {
|
||||
"input",
|
||||
self.uploadExistsDialog
|
||||
).val();
|
||||
if (newName === "") newName = response.suggestion;
|
||||
|
||||
OctoPrint.files
|
||||
.exists("local", path, newName)
|
||||
@@ -1645,13 +1642,22 @@ $(function () {
|
||||
}
|
||||
});
|
||||
});
|
||||
$("a.upload-overwrite", self.uploadExistsDialog)
|
||||
.off("click")
|
||||
.on("click", function () {
|
||||
self.uploadExistsDialog.modal("hide");
|
||||
data.formData = formData;
|
||||
data.submit();
|
||||
});
|
||||
if (
|
||||
self.loginState.hasPermission(
|
||||
self.access.permissions.FILES_DELETE
|
||||
)
|
||||
) {
|
||||
$("a.upload-overwrite", self.uploadExistsDialog)
|
||||
.off("click")
|
||||
.show()
|
||||
.on("click", function () {
|
||||
self.uploadExistsDialog.modal("hide");
|
||||
data.formData = formData;
|
||||
data.submit();
|
||||
});
|
||||
} else {
|
||||
$("a.upload-overwrite", self.uploadExistsDialog).hide();
|
||||
}
|
||||
self.uploadExistsDialog.modal("show");
|
||||
} else {
|
||||
data.formData = formData;
|
||||
|
||||
Reference in new issue
Block a user