From 877306a927b098e25853f38ea792dd5ee663bbfd Mon Sep 17 00:00:00 2001 From: sumneko Date: Sat, 22 Jan 2022 05:11:18 +0800 Subject: skip loaded files --- script/workspace/loading.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'script/workspace') diff --git a/script/workspace/loading.lua b/script/workspace/loading.lua index 8091cadf..1fcd0d77 100644 --- a/script/workspace/loading.lua +++ b/script/workspace/loading.lua @@ -76,8 +76,13 @@ function mt:loadFile(uri, libraryUri) self.max = self.max + 1 self:update() self._stash[#self._stash+1] = function () - local content = util.loadFile(furi.decode(uri)) self.read = self.read + 1 + if files.getFile(uri) then + files.addRef(uri) + log.info(('Skip loaded file: %s'):format(uri)) + return + end + local content = util.loadFile(furi.decode(uri)) self:update() if not content then return @@ -98,8 +103,13 @@ function mt:loadFile(uri, libraryUri) self.max = self.max + 1 self:update() self._stash[#self._stash+1] = function () - local content = util.loadFile(furi.decode(uri)) self.read = self.read + 1 + if files.getFile(uri) then + files.addRef(uri) + log.info(('Skip loaded file: %s'):format(uri)) + return + end + local content = util.loadFile(furi.decode(uri)) self:update() if not content then return -- cgit v1.2.3