From 8eb83ac6a0b3e6e0b50be2b3e60d2eb55bcb9ac4 Mon Sep 17 00:00:00 2001 From: Simon Voordouw Date: Tue, 20 Jun 2017 15:17:29 +0200 Subject: [PATCH] save print id and add it to the progres api --- src/rest/api/api_printer.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index 137926c..0e072a6 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -56,7 +56,17 @@ function M.progress(request, response) -- NOTE: despite their names, `currentLine` is still the error indicator and `bufferedLines` the message in such case. local currentLine,bufferedLines,totalLines,bufferSize,maxBufferSize,seqNumber,seqTotal = printer:getProgress() + local idfile = io.open('/tmp/currentprint') + local printId + if idfile ~= nil then + printId = idfile:read('*a') + end + + response:addData('id', argId) + if printid ~= nil then + response:addData('current_print', printid) + end if currentLine then response:setSuccess() response:addData('current_line', currentLine) @@ -253,6 +263,7 @@ function M.fetch_POST(request, response) return end io.popen("print-fetch " .. socket .. " " .. remote .. " " .. id .. gcodeFiles) + io.open("/tmp/current-print", 'w+').write(id) response:setSuccess() end