@@ -4,7 +4,8 @@ local await = require 'await'
44local files = require ' files'
55local config = require ' config.config'
66local client = require ' client'
7- local pub = require ' pub.pub'
7+ local util = require ' utility'
8+ local furi = require ' file-uri'
89
910--- @class workspace.loading
1011--- @field scp scope
@@ -69,50 +70,48 @@ function mt:loadFile(uri, libraryUri)
6970 end
7071 self .max = self .max + 1
7172 self :update ()
72- pub .task (' loadFile' , uri , function (content )
73- self ._stash [# self ._stash + 1 ] = function ()
74- self .read = self .read + 1
75- self :update ()
76- if not content then
77- return
78- end
79- if self ._cache [uri ] then
80- return
81- end
82- log .info ((' Preload file at: %s , size = %.3f KB' ):format (uri , # content / 1024.0 ))
83- self ._cache [uri ] = true
84- files .setText (uri , content , false )
85- files .addRef (uri )
86- if libraryUri then
87- log .info (' ++++As library of:' , libraryUri )
88- files .setLibraryUri (self .scp , uri , libraryUri )
89- end
73+ self ._stash [# self ._stash + 1 ] = function ()
74+ local content = util .loadFile (furi .decode (uri ))
75+ self .read = self .read + 1
76+ self :update ()
77+ if not content then
78+ return
79+ end
80+ if self ._cache [uri ] then
81+ return
9082 end
91- end )
83+ log .info ((' Preload file at: %s , size = %.3f KB' ):format (uri , # content / 1024.0 ))
84+ self ._cache [uri ] = true
85+ files .setText (uri , content , false )
86+ files .addRef (uri )
87+ if libraryUri then
88+ log .info (' ++++As library of:' , libraryUri )
89+ files .setLibraryUri (self .scp , uri , libraryUri )
90+ end
91+ end
9292 elseif files .isDll (uri ) then
9393 self .max = self .max + 1
9494 self :update ()
95- pub .task (' loadFile' , uri , function (content )
96- self ._stash [# self ._stash + 1 ] = function ()
97- self .read = self .read + 1
98- self :update ()
99- if not content then
100- return
101- end
102- if self ._cache [uri ] then
103- return
104- end
105- log .info ((' Preload dll at: %s , size = %.3f KB' ):format (uri , # content / 1024.0 ))
106- self ._cache [uri ] = true
107- files .saveDll (uri , content )
108- files .addRef (uri )
109- if libraryUri then
110- log .info (' ++++As library of:' , libraryUri )
111- end
95+ self ._stash [# self ._stash + 1 ] = function ()
96+ local content = util .loadFile (furi .decode (uri ))
97+ self .read = self .read + 1
98+ self :update ()
99+ if not content then
100+ return
101+ end
102+ if self ._cache [uri ] then
103+ return
112104 end
113- end )
114- await .delay ()
105+ log .info ((' Preload dll at: %s , size = %.3f KB' ):format (uri , # content / 1024.0 ))
106+ self ._cache [uri ] = true
107+ files .saveDll (uri , content )
108+ files .addRef (uri )
109+ if libraryUri then
110+ log .info (' ++++As library of:' , libraryUri )
111+ end
112+ end
115113 end
114+ await .delay ()
116115end
117116
118117function mt :loadStashed ()
0 commit comments