Skip to content

Commit f5991c0

Browse files
committed
improve
1 parent c513bcd commit f5991c0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

script/workspace/loading.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ function mt:loadFile(uri, libraryUri)
111111
self.read = self.read + 1
112112
self:update()
113113
files.addRef(uri)
114+
self._cache[uri] = true
114115
log.info(('Skip loaded file: %s'):format(uri))
115116
else
116117
local content = pub.awaitTask('loadFile', furi.decode(uri))
@@ -176,7 +177,6 @@ function m.create(scp)
176177
_stash = {},
177178
_cache = {},
178179
}, mt)
179-
scp:set('cachedUris', loading._cache)
180180
m._loadings[loading] = true
181181
return loading
182182
end

script/workspace/workspace.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ function m.awaitLoadFile(uri)
228228
log.info('Scan files at:', uri)
229229
---@async
230230
native:scan(furi.decode(uri), function (path)
231+
scp:get('cachedUris')[furi.encode(path)] = true
231232
ld:loadFile(furi.encode(path))
232233
end)
233234
ld:loadAll()
@@ -275,6 +276,7 @@ function m.awaitPreload(scp)
275276
log.info('Scan files at:', scp:getName())
276277
---@async
277278
native:scan(furi.decode(scp.uri), function (path)
279+
scp:get('cachedUris')[furi.encode(path)] = true
278280
ld:loadFile(furi.encode(path))
279281
end)
280282
end
@@ -284,6 +286,7 @@ function m.awaitPreload(scp)
284286
scp:addLink(libMatcher.uri)
285287
---@async
286288
libMatcher.matcher:scan(furi.decode(libMatcher.uri), function (path)
289+
scp:get('cachedUris')[furi.encode(path)] = true
287290
ld:loadFile(furi.encode(path), libMatcher.uri)
288291
end)
289292
watchers[#watchers+1] = fw.watch(furi.decode(libMatcher.uri))
@@ -401,10 +404,10 @@ end
401404
---@param scp scope
402405
function m.flushFiles(scp)
403406
local cachedUris = scp:get 'cachedUris'
407+
scp:set('cachedUris', {})
404408
if not cachedUris then
405409
return
406410
end
407-
scp:set('cachedUris', nil)
408411
for uri in pairs(cachedUris) do
409412
files.delRef(uri)
410413
end

0 commit comments

Comments
 (0)