Skip to content

Commit 877306a

Browse files
committed
skip loaded files
1 parent 66fe2c2 commit 877306a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

script/workspace/loading.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,13 @@ function mt:loadFile(uri, libraryUri)
7676
self.max = self.max + 1
7777
self:update()
7878
self._stash[#self._stash+1] = function ()
79-
local content = util.loadFile(furi.decode(uri))
8079
self.read = self.read + 1
80+
if files.getFile(uri) then
81+
files.addRef(uri)
82+
log.info(('Skip loaded file: %s'):format(uri))
83+
return
84+
end
85+
local content = util.loadFile(furi.decode(uri))
8186
self:update()
8287
if not content then
8388
return
@@ -98,8 +103,13 @@ function mt:loadFile(uri, libraryUri)
98103
self.max = self.max + 1
99104
self:update()
100105
self._stash[#self._stash+1] = function ()
101-
local content = util.loadFile(furi.decode(uri))
102106
self.read = self.read + 1
107+
if files.getFile(uri) then
108+
files.addRef(uri)
109+
log.info(('Skip loaded file: %s'):format(uri))
110+
return
111+
end
112+
local content = util.loadFile(furi.decode(uri))
103113
self:update()
104114
if not content then
105115
return

0 commit comments

Comments
 (0)