From 2cb8b03f7bffc5c9dc4d9468adbbfc01e1ef0ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 20 Apr 2020 13:39:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Return=20409=20on=20select=20com?= =?UTF-8?q?mand=20if=20print=20is=20ongoing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #3525 --- docs/api/files.rst | 6 ++++-- src/octoprint/server/api/files.py | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/api/files.rst b/docs/api/files.rst index 618567df9..85c479c1c 100644 --- a/docs/api/files.rst +++ b/docs/api/files.rst @@ -572,7 +572,8 @@ Issue a file command is not operational when this parameter is present and set to ``true``, the request will fail with a response of ``409 Conflict``. - Upon success, a status code of :http:statuscode:`204` and an empty body is returned. + Upon success, a status code of :http:statuscode:`204` and an empty body is returned. If there already is an + active print job, a :http:statuscode:`409` is returned. Requires the ``FILES_SELECT`` permission. @@ -768,7 +769,8 @@ Issue a file command :statuscode 400: If the ``command`` is unknown or the request is otherwise invalid :statuscode 415: If a ``slice`` command was issued against something other than an STL file. :statuscode 404: If ``location`` is neither ``local`` nor ``sdcard`` or the requested file was not found - :statuscode 409: If a selected file is supposed to start printing directly but the printer is not operational or + :statuscode 409: If a selected file is supposed to start printing directly but the printer is not operational + or if a file is to be selected but the printer is already printing or if a file to be sliced is supposed to be selected or start printing directly but the printer is not operational or already printing. diff --git a/src/octoprint/server/api/files.py b/src/octoprint/server/api/files.py index 6ea51da02..78641dd36 100644 --- a/src/octoprint/server/api/files.py +++ b/src/octoprint/server/api/files.py @@ -535,6 +535,9 @@ def gcodeFileCommand(filename, target): if not octoprint.filemanager.valid_file_type(filename, type="machinecode"): return make_response("Cannot select {filename} for printing, not a machinecode file".format(**locals()), 415) + if not printer.is_ready(): + return make_response("Printer is already printing, cannot select a new file", 409) + printAfterLoading = False if "print" in data and data["print"] in valid_boolean_trues: with Permissions.PRINT.require(403):