summaryrefslogtreecommitdiff
path: root/script/brave/work.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/brave/work.lua')
-rw-r--r--script/brave/work.lua20
1 files changed, 15 insertions, 5 deletions
diff --git a/script/brave/work.lua b/script/brave/work.lua
index 49c90f83..90ed6f6f 100644
--- a/script/brave/work.lua
+++ b/script/brave/work.lua
@@ -1,9 +1,4 @@
local brave = require 'brave.brave'
-local parser = require 'parser'
-local fs = require 'bee.filesystem'
-local furi = require 'file-uri'
-local util = require 'utility'
-local thread = require 'bee.thread'
brave.on('loadProto', function ()
local jsonrpc = require 'jsonrpc'
@@ -19,6 +14,7 @@ brave.on('loadProto', function ()
end)
brave.on('timer', function (time)
+ local thread = require 'bee.thread'
while true do
thread.sleep(time)
brave.push('wakeup')
@@ -26,5 +22,19 @@ brave.on('timer', function (time)
end)
brave.on('loadFile', function (path)
+ local util = require 'utility'
return util.loadFile(path)
end)
+
+brave.on('removeCaches', function(path)
+ local fs = require 'bee.filesystem'
+ local fsu = require 'fs-utility'
+ for dir in fs.pairs(fs.path(path)) do
+ local lockFile = dir / '.lock'
+ local f = io.open(lockFile:string(), 'wb')
+ if f then
+ f:close()
+ fsu.fileRemove(dir)
+ end
+ end
+end)