@@ -167,21 +167,26 @@ type Archive = {
167167 dirMap : DirectoryHierarchyMap ;
168168} ;
169169
170+ async function parse_zip ( zipPath : string ) : Promise < Archive > {
171+ if ( ! await fs . pathExists ( zipPath ) )
172+ throw vscode . FileSystemError . FileNotFound ( zipPath ) ;
173+ const archive : Archive = { unzipped : await unzipper . Open . file ( zipPath ) , dirMap : new Map } ;
174+ archive . unzipped . files . forEach ( f => { ensureFile ( archive . dirMap , path . resolve ( '/' , f . path ) ) ; } ) ;
175+ return archive ;
176+ }
177+
170178export class ArchiveFileSystemProvider implements vscode . FileSystemProvider {
171179 private readOnlyError = vscode . FileSystemError . NoPermissions ( 'write operation attempted, but source archive filesystem is readonly' ) ;
172- private archives : Map < string , Archive > = new Map ;
180+ private archives : Map < string , Promise < Archive > > = new Map ;
173181
174182 private async getArchive ( zipPath : string ) : Promise < Archive > {
175183 if ( ! this . archives . has ( zipPath ) ) {
176- if ( ! await fs . pathExists ( zipPath ) )
177- throw vscode . FileSystemError . FileNotFound ( zipPath ) ;
178- const archive : Archive = { unzipped : await unzipper . Open . file ( zipPath ) , dirMap : new Map } ;
179- archive . unzipped . files . forEach ( f => { ensureFile ( archive . dirMap , path . resolve ( '/' , f . path ) ) ; } ) ;
180- this . archives . set ( zipPath , archive ) ;
184+ this . archives . set ( zipPath , parse_zip ( zipPath ) ) ;
181185 }
182- return this . archives . get ( zipPath ) ! ;
186+ return await this . archives . get ( zipPath ) ! ;
183187 }
184188
189+
185190 root = new Directory ( '' ) ;
186191
187192 // metadata
0 commit comments