From 0c79a51083388e2eba6e04cef3791a4a0b927713 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Mon, 28 Oct 2013 19:38:53 +0100 Subject: [PATCH] Add status request to sketch api. Keep sketch directory over upgrades. --- post-install.sh | 3 +++ src/rest/api/api_sketch.lua | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/post-install.sh b/post-install.sh index a0f6640..6bf66ca 100644 --- a/post-install.sh +++ b/post-install.sh @@ -67,6 +67,9 @@ if [ $? -gt 0 ]; then EOM fi +#preserve saved sketches during firmware update +echo "/root/sketches" >> /etc/sysupgrade.conf + ### Finally make sure basic configuration is set correctly $IPKG_INSTROOT/etc/init.d/wifibox enable diff --git a/src/rest/api/api_sketch.lua b/src/rest/api/api_sketch.lua index b255598..9e25d00 100644 --- a/src/rest/api/api_sketch.lua +++ b/src/rest/api/api_sketch.lua @@ -140,10 +140,16 @@ function M._global_POST(request, response) response:setSuccess() end --- get info on number of sketches, used space, free space (and reserved space for printserver?) +-- TODO: return total space used by sketches? (createSketchList() could just as well collect size info too...see lfs.attributes) function M.status(request, response) if not createSketchDirectory(request, response) then return end - --return amount of sketches, free space (and space used by sketches?) + local sketches = createSketchList() + + local listSize = table.getn(sketches) + response:addData('number_of_sketches', table.getn(sketches)) + response:addData('available', getFreeDiskSpace()) + response:addData('reserved', M.MIN_FREE_SPACE) + response:setSuccess() end