@@ -11,6 +11,8 @@ import { Event, Emitter } from 'vs/base/common/event';
1111import { IDownloadService } from 'vs/platform/download/common/download' ;
1212import { mkdirp } from 'vs/base/node/pfs' ;
1313import { IURITransformer } from 'vs/base/common/uriIpc' ;
14+ import { tmpdir } from 'os' ;
15+ import { generateUuid } from 'vs/base/common/uuid' ;
1416
1517export type UploadResponse = Buffer | string | undefined ;
1618
@@ -46,21 +48,21 @@ export class DownloadServiceChannelClient implements IDownloadService {
4648
4749 constructor ( private channel : IChannel , private getUriTransformer : ( ) => IURITransformer ) { }
4850
49- download ( from : URI , to : string ) : Promise < void > {
51+ download ( from : URI , to : string = path . join ( tmpdir ( ) , generateUuid ( ) ) ) : Promise < string > {
5052 from = this . getUriTransformer ( ) . transformOutgoingURI ( from ) ;
5153 const dirName = path . dirname ( to ) ;
5254 let out : fs . WriteStream ;
53- return new Promise ( ( c , e ) => {
55+ return new Promise < string > ( ( c , e ) => {
5456 return mkdirp ( dirName )
5557 . then ( ( ) => {
5658 out = fs . createWriteStream ( to ) ;
57- out . once ( 'close' , ( ) => c ( ) ) ;
59+ out . once ( 'close' , ( ) => c ( to ) ) ;
5860 out . once ( 'error' , e ) ;
5961 const uploadStream = this . channel . listen < UploadResponse > ( 'upload' , from ) ;
6062 const disposable = uploadStream ( result => {
6163 if ( result === undefined ) {
6264 disposable . dispose ( ) ;
63- out . end ( c ) ;
65+ out . end ( ( ) => c ( to ) ) ;
6466 } else if ( Buffer . isBuffer ( result ) ) {
6567 out . write ( result ) ;
6668 } else if ( typeof result === 'string' ) {
@@ -71,4 +73,4 @@ export class DownloadServiceChannelClient implements IDownloadService {
7173 } ) ;
7274 } ) ;
7375 }
74- }
76+ }
0 commit comments