@@ -32,15 +32,18 @@ export class SshUssApi implements MainframeInteraction.IUss {
32
32
public async fileList ( ussFilePath : string ) : Promise < zosfiles . IZosFilesResponse > {
33
33
return this . withClient ( this . getSession ( ) , async ( client ) => {
34
34
const response = [ ] ;
35
- for ( const fileInfo of await client . list ( ussFilePath ) ) {
36
- response . push ( {
37
- name : fileInfo . name ,
38
- mode : fileInfo . type + fileInfo . owner + fileInfo . group + fileInfo . rights . other ,
39
- size : fileInfo . size ,
40
- uid : fileInfo . owner ,
41
- gid : fileInfo . group ,
42
- mtime : fileInfo . modifyTime . toString ( ) ,
43
- } ) ;
35
+ if ( ( await client . stat ( ussFilePath ) ) . isDirectory ) {
36
+ for ( const fileInfo of await client . list ( ussFilePath ) ) {
37
+ const permString = Object . values ( fileInfo . rights ) . reduce ( ( all , perm ) => all . concat ( perm ) , fileInfo . type ) ;
38
+ response . push ( {
39
+ name : fileInfo . name ,
40
+ mode : permString ,
41
+ size : fileInfo . size ,
42
+ uid : fileInfo . owner ,
43
+ gid : fileInfo . group ,
44
+ mtime : fileInfo . modifyTime ,
45
+ } ) ;
46
+ }
44
47
}
45
48
return this . buildZosFilesResponse ( { items : response } ) ;
46
49
} ) ;
@@ -50,12 +53,16 @@ export class SshUssApi implements MainframeInteraction.IUss {
50
53
return Promise . resolve ( false ) ;
51
54
}
52
55
53
- public async getContents ( ussFilePath : string , options : zosfiles . IDownloadOptions ) : Promise < zosfiles . IZosFilesResponse > {
56
+ public async getContents ( ussFilePath : string , options : zosfiles . IDownloadSingleOptions ) : Promise < zosfiles . IZosFilesResponse > {
54
57
return this . withClient ( this . getSession ( ) , async ( client ) => {
55
- const localPath = options . file as string ;
56
- imperative . IO . createDirsSyncFromFilePath ( localPath ) ;
57
- const response = await client . fastGet ( ussFilePath , localPath ) ;
58
- return this . buildZosFilesResponse ( response ) ;
58
+ if ( options . file != null ) {
59
+ imperative . IO . createDirsSyncFromFilePath ( options . file ) ;
60
+ await client . fastGet ( ussFilePath , options . file ) ;
61
+ } else if ( options . stream != null ) {
62
+ options . stream . write ( await client . get ( ussFilePath ) ) ;
63
+ options . stream . end ( ) ;
64
+ }
65
+ return this . buildZosFilesResponse ( { etag : ussFilePath } ) ;
59
66
} ) ;
60
67
}
61
68
@@ -66,7 +73,7 @@ export class SshUssApi implements MainframeInteraction.IUss {
66
73
} ) ;
67
74
}
68
75
69
- public async putContent ( inputFilePath : string , ussFilePath : string ) : Promise < zosfiles . IZosFilesResponse > {
76
+ public async putContent ( inputFilePath : string , ussFilePath : string , _options ?: zosfiles . IUploadOptions ) : Promise < zosfiles . IZosFilesResponse > {
70
77
return this . withClient ( this . getSession ( ) , async ( client ) => {
71
78
const response = await client . fastPut ( inputFilePath , ussFilePath ) ;
72
79
return this . buildZosFilesResponse ( response ) ;
@@ -119,6 +126,9 @@ export class SshUssApi implements MainframeInteraction.IUss {
119
126
password : session . ISession . password ,
120
127
} ) ;
121
128
return await callback ( client ) ;
129
+ } catch ( err ) {
130
+ console . error ( err ) ;
131
+ return Promise . reject < T > ( err ) ;
122
132
} finally {
123
133
await client . end ( ) ;
124
134
}
0 commit comments