From e39e512e487dbf2a812bda4aeb636488da57c4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 6 Oct 2016 17:12:18 +0200 Subject: [PATCH] Fixed an issue with the file move API command --- src/octoprint/server/api/files.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/octoprint/server/api/files.py b/src/octoprint/server/api/files.py index 4241769d..12012087 100644 --- a/src/octoprint/server/api/files.py +++ b/src/octoprint/server/api/files.py @@ -637,12 +637,12 @@ def gcodeFileCommand(filename, target): if not _verifyFileExists(target, filename) and not _verifyFolderExists(target, filename): return make_response("File or folder not found on {}: {}".format(target, filename), 404) - destination = data["destination"] - if not _verifyFolderExists(target, destination): - return make_response("Destination folder not found on {}: {}".format(target, destination), 404) - path, name = fileManager.split_path(target, filename) - destination = fileManager.join_path(target, destination, name) + destination = data["destination"] + if _verifyFolderExists(target, destination): + # destination is an existing folder, 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): return make_response("File or folder does already exist on {}: {}".format(target, destination), 409)