@@ -81,13 +81,15 @@ function mt:loadFile(uri, libraryUri)
81
81
if files .getFile (uri ) then
82
82
self .read = self .read + 1
83
83
self :update ()
84
+ files .addRef (uri )
85
+ self ._cache [uri ] = true
84
86
log .info ((' Skip loaded file: %s' ):format (uri ))
85
87
else
86
88
local content = pub .awaitTask (' loadFile' , furi .decode (uri ))
87
89
self .read = self .read + 1
88
90
self :update ()
89
- if self ._cache [uri ] then
90
- return
91
+ if not self ._cache [uri ] then
92
+ files . addRef ( uri )
91
93
end
92
94
self ._cache [uri ] = true
93
95
if not content then
@@ -96,7 +98,6 @@ function mt:loadFile(uri, libraryUri)
96
98
log .info ((' Preload file at: %s , size = %.3f KB' ):format (uri , # content / 1024.0 ))
97
99
files .setText (uri , content , false )
98
100
end
99
- files .addRef (uri )
100
101
if libraryUri then
101
102
log .info (' ++++As library of:' , libraryUri )
102
103
end
@@ -109,13 +110,14 @@ function mt:loadFile(uri, libraryUri)
109
110
if files .getFile (uri ) then
110
111
self .read = self .read + 1
111
112
self :update ()
113
+ files .addRef (uri )
112
114
log .info ((' Skip loaded file: %s' ):format (uri ))
113
115
else
114
116
local content = pub .awaitTask (' loadFile' , furi .decode (uri ))
115
117
self .read = self .read + 1
116
118
self :update ()
117
- if self ._cache [uri ] then
118
- return
119
+ if not self ._cache [uri ] then
120
+ files . addRef ( uri )
119
121
end
120
122
self ._cache [uri ] = true
121
123
if not content then
@@ -124,7 +126,6 @@ function mt:loadFile(uri, libraryUri)
124
126
log .info ((' Preload dll at: %s , size = %.3f KB' ):format (uri , # content / 1024.0 ))
125
127
files .saveDll (uri , content )
126
128
end
127
- files .addRef (uri )
128
129
if libraryUri then
129
130
log .info (' ++++As library of:' , libraryUri )
130
131
end
0 commit comments