mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 19:13:49 +01:00
Fix logfile saving if ultifi path does not exist; fix http response consistency.
This commit is contained in:
parent
d59d2da938
commit
dfb16a9b32
@ -38,6 +38,8 @@ function M.logfiles(request, response)
|
|||||||
local rv,msg = lfs.mkdir(LOG_COLLECT_DIR)
|
local rv,msg = lfs.mkdir(LOG_COLLECT_DIR)
|
||||||
local rv,msg = lfs.chdir(TMP_DIR)
|
local rv,msg = lfs.chdir(TMP_DIR)
|
||||||
|
|
||||||
|
local ultip,msg = lfs.attributes(ULTIFI_PATH, 'mode')
|
||||||
|
|
||||||
|
|
||||||
--[[ create temporary files ]]--
|
--[[ create temporary files ]]--
|
||||||
|
|
||||||
@ -45,6 +47,7 @@ function M.logfiles(request, response)
|
|||||||
|
|
||||||
local rv,sig,code = os.execute('logread > ' .. LOG_COLLECT_DIR .. '/' .. SYSLOG_FILENAME)
|
local rv,sig,code = os.execute('logread > ' .. LOG_COLLECT_DIR .. '/' .. SYSLOG_FILENAME)
|
||||||
|
|
||||||
|
if ultip and ultip == 'directory' then
|
||||||
for file in lfs.dir(ULTIFI_PATH) do
|
for file in lfs.dir(ULTIFI_PATH) do
|
||||||
if file ~= '.' and file ~= '..' then
|
if file ~= '.' and file ~= '..' then
|
||||||
local srcLogFile = ULTIFI_PATH .. '/' .. file .. '/' .. ULTIFI_LOG_FILENAME
|
local srcLogFile = ULTIFI_PATH .. '/' .. file .. '/' .. ULTIFI_LOG_FILENAME
|
||||||
@ -52,6 +55,7 @@ function M.logfiles(request, response)
|
|||||||
local rv,sig,code = redirectedExecute('cp ' .. srcLogFile .. ' ' .. tgtLogFile)
|
local rv,sig,code = redirectedExecute('cp ' .. srcLogFile .. ' ' .. tgtLogFile)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local rv,sig,code = redirectedExecute('tar czf ' .. LOG_COLLECT_ARCHIVE_FILE .. ' ' .. LOG_COLLECT_DIRNAME) --returns 0 success, 1 error
|
local rv,sig,code = redirectedExecute('tar czf ' .. LOG_COLLECT_ARCHIVE_FILE .. ' ' .. LOG_COLLECT_DIRNAME) --returns 0 success, 1 error
|
||||||
|
|
||||||
@ -68,12 +72,14 @@ function M.logfiles(request, response)
|
|||||||
|
|
||||||
--[[ remove temporary files ]]--
|
--[[ remove temporary files ]]--
|
||||||
|
|
||||||
|
if ultip and ultip == 'directory' then
|
||||||
for file in lfs.dir(ULTIFI_PATH) do
|
for file in lfs.dir(ULTIFI_PATH) do
|
||||||
if file ~= '.' and file ~= '..' then
|
if file ~= '.' and file ~= '..' then
|
||||||
local tgtLogFile = LOG_COLLECT_DIR .. '/' .. file .. '-' .. ULTIFI_LOG_FILENAME
|
local tgtLogFile = LOG_COLLECT_DIR .. '/' .. file .. '-' .. ULTIFI_LOG_FILENAME
|
||||||
local rv,sig,code = redirectedExecute('rm ' .. tgtLogFile)
|
local rv,sig,code = redirectedExecute('rm ' .. tgtLogFile)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/' .. WIFIBOX_LOG_FILENAME)
|
local rv,sig,code = redirectedExecute('rm ' .. LOG_COLLECT_DIR .. '/' .. WIFIBOX_LOG_FILENAME)
|
||||||
|
|
||||||
|
@ -88,14 +88,14 @@ end
|
|||||||
|
|
||||||
function M:send()
|
function M:send()
|
||||||
printHeaderLine("Status", self.httpStatusCode .. " " .. self.httpStatusText)
|
printHeaderLine("Status", self.httpStatusCode .. " " .. self.httpStatusText)
|
||||||
printHeaderLine("Content-type", self.contentType)
|
printHeaderLine("Content-Type", self.contentType)
|
||||||
printHeaderLine("Access-Control-Allow-Origin", "*")
|
printHeaderLine("Access-Control-Allow-Origin", "*")
|
||||||
|
|
||||||
if self.binaryData == nil then
|
if self.binaryData == nil then
|
||||||
io.write("\r\n")
|
io.write("\r\n")
|
||||||
print(self:serializeAsJson())
|
print(self:serializeAsJson())
|
||||||
else
|
else
|
||||||
printHeaderLine("content-disposition", "attachment;filename=" .. self.binarySavename)
|
printHeaderLine("Content-Disposition", "attachment; filename=" .. self.binarySavename)
|
||||||
io.write("\r\n")
|
io.write("\r\n")
|
||||||
io.write(self.binaryData)
|
io.write(self.binaryData)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user