From 74f4749dc840e169ac25b7848f1f882b62388871 Mon Sep 17 00:00:00 2001 From: sumneko Date: Tue, 16 Apr 2019 17:35:24 +0800 Subject: =?UTF-8?q?=E5=8A=A0=E4=B8=AA=E7=BA=BF=E7=A8=8B=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/async/loadfile.lua | 12 ++++++++++++ server/src/async/scanfiles.lua | 8 +------- 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 server/src/async/loadfile.lua (limited to 'server/src/async') diff --git a/server/src/async/loadfile.lua b/server/src/async/loadfile.lua new file mode 100644 index 00000000..e5f270fb --- /dev/null +++ b/server/src/async/loadfile.lua @@ -0,0 +1,12 @@ +require 'utility' +local fs = require 'bee.filesystem' + +while true do + local filename = IN:bpop() + local buf = io.load(fs.path(filename)) + if buf then + OUT:push(filename, buf) + end + collectgarbage() + GC:push(ID, collectgarbage 'count') +end diff --git a/server/src/async/scanfiles.lua b/server/src/async/scanfiles.lua index eb3073df..f54b0866 100644 --- a/server/src/async/scanfiles.lua +++ b/server/src/async/scanfiles.lua @@ -47,13 +47,7 @@ for path in scan(fs.path(args.root), filter) do OUT:push 'stop' return end - local buf = io.load(path) - if buf then - OUT:push('file', { - path = fs.absolute(path):string(), - buf = buf, - }) - end + OUT:push('path', fs.absolute(path):string()) end OUT:push 'ok' -- cgit v1.2.3