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):