@@ -6,6 +6,7 @@ import { Directory } from "./Directory";
6
6
import { File } from "./File" ;
7
7
import { fireOtherStudioAction , OtherStudioAction } from "../../commands/studio" ;
8
8
import { StudioOpenDialog } from "../../queries" ;
9
+ import { redirectDotvscodeRoot } from "../../utils/index" ;
9
10
10
11
declare function setTimeout ( callback : ( ...args : any [ ] ) => void , ms : number , ...args : any [ ] ) : NodeJS . Timeout ;
11
12
@@ -61,7 +62,13 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
61
62
} else {
62
63
filter = "*.cls,*.inc,*.mac,*.int" ;
63
64
}
64
- const folder = csp ? ( uri . path . endsWith ( "/" ) ? uri . path : uri . path + "/" ) : uri . path . replace ( / \/ / g, "." ) ;
65
+ const folder = ! csp
66
+ ? uri . path . replace ( / \/ / g, "." )
67
+ : uri . path === "/"
68
+ ? ""
69
+ : uri . path . endsWith ( "/" )
70
+ ? uri . path
71
+ : uri . path + "/" ;
65
72
const spec = csp ? folder + filter : folder . length > 1 ? folder . slice ( 1 ) + "/" + filter : filter ;
66
73
const dir = "1" ;
67
74
const orderBy = "1" ;
@@ -72,18 +79,48 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
72
79
return api
73
80
. actionQuery ( sql , [ spec , dir , orderBy , system , flat , notStudio , generated ] )
74
81
. then ( ( data ) => data . result . content || [ ] )
75
- . then ( ( data ) =>
76
- data . map ( ( item : StudioOpenDialog ) => {
77
- const name = item . Name ;
82
+ . then ( ( data ) => {
83
+ const results = data . map ( ( item : StudioOpenDialog ) => {
84
+ // Handle how query returns web apps
85
+ const name = item . Name . split ( "/" ) [ 0 ] ;
78
86
const fullName = folder === "" ? name : folder + "/" + name ;
79
87
if ( item . Type === "10" || item . Type === "9" ) {
80
88
parent . entries . set ( name , new Directory ( name , fullName ) ) ;
81
89
return [ name , vscode . FileType . Directory ] ;
82
90
} else {
83
91
return [ name , vscode . FileType . File ] ;
84
92
}
85
- } )
86
- )
93
+ } ) ;
94
+ if ( ! csp || results . length ) {
95
+ return results ;
96
+ }
97
+ //TODO further request(s) to get the next level in CSP app names
98
+ // e.g. folder root is isfs://server/?ns=USER&csp
99
+ // and USER namespace is the home of /csp/app1 and /csp/app2
100
+ // Initial expand showed the csp folder.
101
+ // Expand of that came here and asked Studio dialog query for /csp/*
102
+ // but this doesn't return app1 and app2 folders.
103
+ return api
104
+ . actionQuery ( sql , [ "/*.CSPALL" , dir , orderBy , system , flat , notStudio , generated ] )
105
+ . then ( ( data ) => data . result . content || [ ] )
106
+ . then ( ( data ) => {
107
+ return results ;
108
+ /*
109
+ const results = data.map((item: StudioOpenDialog) => {
110
+ // Handle how query returns web apps
111
+ const name = item.Name.split("/")[0];
112
+ const fullName = folder === "" ? name : folder + "/" + name;
113
+ if (item.Type === "10" || item.Type === "9") {
114
+ parent.entries.set(name, new Directory(name, fullName));
115
+ return [name, vscode.FileType.Directory];
116
+ } else {
117
+ return [name, vscode.FileType.File];
118
+ }
119
+ });
120
+ return results;
121
+ */
122
+ } ) ;
123
+ } )
87
124
. catch ( ( error ) => {
88
125
error && console . error ( error ) ;
89
126
} ) ;
@@ -138,16 +175,17 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
138
175
overwrite : boolean ;
139
176
}
140
177
) : void | Thenable < void > {
141
- if ( uri . path . match ( / \/ \. [ ^ / ] * \/ / ) ) {
178
+ uri = redirectDotvscodeRoot ( uri ) ;
179
+ if ( uri . path . startsWith ( "/." ) ) {
142
180
throw vscode . FileSystemError . NoPermissions ( "dot-folders not supported by server" ) ;
143
181
}
182
+ const api = new AtelierAPI ( uri ) ;
144
183
const { query } = url . parse ( decodeURIComponent ( uri . toString ( ) ) , true ) ;
145
184
const csp = query . csp === "" || query . csp === "1" ;
146
185
const fileName = csp ? uri . path : uri . path . slice ( 1 ) . replace ( / \/ / g, "." ) ;
147
186
if ( fileName . startsWith ( "." ) ) {
148
187
return ;
149
188
}
150
- const api = new AtelierAPI ( uri ) ;
151
189
return this . _lookupAsFile ( uri ) . then (
152
190
( ) => {
153
191
// Weirdly, if the file exists on the server we don't actually write its content here.
@@ -274,15 +312,16 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
274
312
275
313
// Fetch from server and cache it
276
314
private async _lookupAsFile ( uri : vscode . Uri ) : Promise < File > {
277
- // Reject attempts to access files in .-folders such as .vscode and .git
278
- if ( uri . path . match ( / \/ \. [ ^ / ] * \/ / ) ) {
279
- throw vscode . FileSystemError . FileNotFound ( "dot-folders not supported by server" ) ;
315
+ uri = redirectDotvscodeRoot ( uri ) ;
316
+ if ( uri . path . startsWith ( "/." ) ) {
317
+ throw vscode . FileSystemError . NoPermissions ( "dot-folders not supported by server" ) ;
280
318
}
319
+
320
+ const api = new AtelierAPI ( uri ) ;
281
321
const { query } = url . parse ( decodeURIComponent ( uri . toString ( ) ) , true ) ;
282
322
const csp = query . csp === "" || query . csp === "1" ;
283
323
const fileName = csp ? uri . path : uri . path . slice ( 1 ) . replace ( / \/ / g, "." ) ;
284
324
const name = path . basename ( uri . path ) ;
285
- const api = new AtelierAPI ( uri ) ;
286
325
return api
287
326
. getDoc ( fileName )
288
327
. then ( ( data ) => data . result )
0 commit comments