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