diff --git a/AUTHORS.md b/AUTHORS.md index 4cdb3fed6..85ae55889 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -143,6 +143,7 @@ date of first contribution): * [Karthikeyan Singaravelan](https://github.com/tirkarthi) * [Yvan Rodrigues](https://github.com/TwoRedCells) * [Elton Law](https://github.com/eltonlaw) + * ["sparxooo"] (https://github.com/sparxooo) OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by [Daid Braam](https://github.com/daid). Parts of its communication layer and diff --git a/src/octoprint/server/api/files.py b/src/octoprint/server/api/files.py index a5d5b43dd..6453ce070 100644 --- a/src/octoprint/server/api/files.py +++ b/src/octoprint/server/api/files.py @@ -1088,18 +1088,25 @@ def gcodeFileCommand(filename, target): target, dst_path, fileManager.sanitize_name(target, dst_name) ) - if ( - _verifyFolderExists(target, destination) - and sanitized_destination != filename - ): - # destination is an existing folder and not ourselves (= display rename), we'll assume we are supposed - # to move filename to this folder under the same name - destination = fileManager.join_path(target, destination, name) + # Check for exception thrown by _verifyFolderExists, if outside the root directory + try: + if ( + _verifyFolderExists(target, destination) + and sanitized_destination != filename + ): + # destination is an existing folder and not ourselves (= display rename), we'll assume we are supposed + # to move filename to this folder under the same name + destination = fileManager.join_path(target, destination, name) - if _verifyFileExists(target, destination) or _verifyFolderExists( - target, destination - ): - abort(409, description="File or folder does already exist") + if _verifyFileExists(target, destination) or _verifyFolderExists( + target, destination + ): + abort(409, description="File or folder does already exist") + + except Exception: + abort( + 409, description="Exception thrown by storage, bad folder/file name?" + ) is_file = fileManager.file_exists(target, filename) is_folder = fileManager.folder_exists(target, filename) diff --git a/src/octoprint/static/js/app/viewmodels/files.js b/src/octoprint/static/js/app/viewmodels/files.js index 66676a7d8..953816b4a 100644 --- a/src/octoprint/static/js/app/viewmodels/files.js +++ b/src/octoprint/static/js/app/viewmodels/files.js @@ -83,6 +83,20 @@ $(function () { self.moveEntry = ko.observable({name: "", display: "", path: ""}); // is there a better way to do this? self.moveSource = ko.observable(undefined); self.moveDestination = ko.observable(undefined); + self.moveSourceFilename = ko.observable(undefined); + self.moveDestinationFilename = ko.observable(undefined); + self.moveDestinationFullpath = ko.pureComputed(function () { + // Join the paths for renaming + if (self.moveSourceFilename() != self.moveDestinationFilename()) { + if (self.moveDestination() === "/") { + return self.moveDestination() + self.moveDestinationFilename(); + } else { + return self.moveDestination() + "/" + self.moveDestinationFilename(); + } + } else { + return self.moveDestination(); + } + }); self.moveError = ko.observable(""); self.folderList = ko.observableArray(["/"]); @@ -680,6 +694,8 @@ $(function () { self.moveError(""); self.moveSource(current); self.moveDestination(current); + self.moveSourceFilename(entry.name); + self.moveDestinationFilename(entry.name); self.moveDialog.modal("show"); }; diff --git a/src/octoprint/templates/dialogs/files.jinja2 b/src/octoprint/templates/dialogs/files.jinja2 index 75cc5e71e..266a73c54 100644 --- a/src/octoprint/templates/dialogs/files.jinja2 +++ b/src/octoprint/templates/dialogs/files.jinja2 @@ -33,12 +33,18 @@ + +
+ +
+ +

{{ _('File/Folder will be moved to: ') }}