From 5467f2ddadeaaf74dfb2109d53c4d5be9f275f20 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Mon, 16 Sep 2013 16:05:32 +0300 Subject: integration with 'lbu commit' client must specifically request saving files if server's root file system is tmpfs web client does this automatically on commit --- server.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'server.lua') diff --git a/server.lua b/server.lua index 7168c0e..9a17c44 100644 --- a/server.lua +++ b/server.lua @@ -13,6 +13,8 @@ local stringy = require('stringy') math.randomseed(os.time()) +local save_req = os.execute('[ $(stat -f -c "%T" /) = tmpfs ]') + -- TODO shared storage for sessions -- TODO expire stale sessions local sessions = {} @@ -98,7 +100,13 @@ return function(env) until not sessions[sid] sessions[sid] = {user=data.username, last_txn_id=0, txns={}} - return wrap(204, {['X-ACF-Auth-Token']=sid}) + return wrap( + 204, + { + ['X-ACF-Auth-Token']=sid, + ['X-ACF-Save-Required']=save_req and 1 or 0 + } + ) end return wrap(401) end @@ -115,6 +123,13 @@ return function(env) if not user then return wrap(401) end + if path == '/save' then + if not save_req then return wrap(404) end + if method ~= 'POST' then return wrap(405) end + if os.execute('lbu commit') then wrap(204) end + return wrap(500, nil, 'lbu commit failed') + end + local success, code, hdr, res = acf.call( function() if stringy.startswith(path, '/meta/') then -- cgit v1.2.3