@@ -315,7 +315,7 @@ function postLaunchHook(extensionCtx: vscode.ExtensionContext) {
315
315
if ( isFirstLaunch ) {
316
316
317
317
// setup install time
318
- resManager . setAppUsrData ( 'InstallTime' , Date . now ( ) . toString ( ) ) ;
318
+ resManager . setAppUsrData ( 'InstallTime' , Date . now ( ) ) ;
319
319
320
320
// only enable github proxy for GMT+8:00 by default
321
321
const timeZone = Math . floor ( ( new Date ( ) . getTimezoneOffset ( ) / 60 ) * - 1 ) ;
@@ -328,10 +328,16 @@ function postLaunchHook(extensionCtx: vscode.ExtensionContext) {
328
328
// not first launch
329
329
else {
330
330
331
+ // fix type error for old version
332
+ if ( typeof appUsrData [ 'InstallTime' ] === 'string' ) {
333
+ appUsrData [ 'InstallTime' ] = parseInt ( appUsrData [ 'InstallTime' ] ) || 0 ;
334
+ resManager . setAppUsrData ( 'InstallTime' , appUsrData [ 'InstallTime' ] ) ;
335
+ }
336
+
331
337
// A few days ago, show feedback message
332
- const some_days = 7 * ( 24 * 3600 * 1000 ) ;
338
+ const some_days = 7 * utility . TIME_ONE_DAY ;
333
339
if ( ! appUsrData [ 'Feedbacked' ] &&
334
- Date . now ( ) - appUsrData [ 'InstallTime' ] > some_days ) {
340
+ Date . now ( ) > appUsrData [ 'InstallTime' ] + some_days ) {
335
341
resManager . setAppUsrData ( 'Feedbacked' , true ) ;
336
342
const msg = view_str$prompt$feedback ;
337
343
vscode . window . showInformationMessage ( msg , rating_text , sponsor_author_text ) . then ( ( ans ) => {
@@ -433,9 +439,10 @@ async function checkAndInstallBinaries(forceInstall?: boolean): Promise<boolean>
433
439
}
434
440
435
441
/* check eide binaries */
436
- // if user force reinstall, delete old 'bin' dir
442
+
443
+ // force reinstall
437
444
if ( forceInstall ) {
438
- platform . DeleteDir ( binFolder ) ;
445
+ return await tryUpdateBinaries ( binFolder , undefined ) ;
439
446
}
440
447
441
448
// if binaries is installed, we need check binaries's version
@@ -461,12 +468,18 @@ async function checkAndInstallBinaries(forceInstall?: boolean): Promise<boolean>
461
468
// try fetch update after 5sec delay
462
469
if ( localVersion ) {
463
470
setTimeout ( async ( curLocalVersion : string ) => {
464
- const done = await tryUpdateBinaries ( binFolder , curLocalVersion , true ) ; // no prompt
465
- if ( ! done ) {
466
- const msg = `Update eide-binaries failed, please restart vscode to try again !` ;
467
- const sel = await vscode . window . showErrorMessage ( msg , 'Restart' , 'Cancel' ) ;
468
- if ( sel == 'Restart' ) {
469
- vscode . commands . executeCommand ( 'workbench.action.reloadWindow' ) ;
471
+ const appUsrData = resManager . getAppUsrData ( ) || { } ;
472
+ const lastCheckUpdateTime : number = appUsrData [ 'LastCheckBinariesUpdateTime' ] || 0 ;
473
+ if ( Date . now ( ) > lastCheckUpdateTime + ( 6 * utility . TIME_ONE_HOUR ) ) {
474
+ const done = await tryUpdateBinaries ( binFolder , curLocalVersion ) ; // no prompt
475
+ if ( done ) {
476
+ resManager . setAppUsrData ( 'LastCheckBinariesUpdateTime' , Date . now ( ) ) ;
477
+ } else {
478
+ const msg = `Update eide-binaries failed, please restart vscode to try again !` ;
479
+ const sel = await vscode . window . showErrorMessage ( msg , 'Restart' , 'Cancel' ) ;
480
+ if ( sel == 'Restart' ) {
481
+ vscode . commands . executeCommand ( 'workbench.action.reloadWindow' ) ;
482
+ }
470
483
}
471
484
}
472
485
} , 5 * 1000 , localVersion ) ;
@@ -476,7 +489,7 @@ async function checkAndInstallBinaries(forceInstall?: boolean): Promise<boolean>
476
489
// the binaries maybe damaged, we need to force reinstall it
477
490
else {
478
491
platform . DeleteDir ( binFolder ) ; // del existed folder
479
- return await tryUpdateBinaries ( binFolder , undefined , true ) ;
492
+ return await tryUpdateBinaries ( binFolder , undefined ) ;
480
493
}
481
494
482
495
// export current binaries version
@@ -491,10 +504,13 @@ async function checkAndInstallBinaries(forceInstall?: boolean): Promise<boolean>
491
504
}
492
505
493
506
// not found binaries folder, install it
494
- return await tryUpdateBinaries ( binFolder , undefined , true ) ;
507
+ return await tryUpdateBinaries ( binFolder , undefined ) ;
495
508
}
496
509
497
- async function tryUpdateBinaries ( binFolder : File , localVer ?: string , notConfirm ?: boolean ) : Promise < boolean > {
510
+ /**
511
+ * @param localVer 当前本地的版本号,通过比对版本号决定是否执行安装,如果为 undefined 则强制安装
512
+ */
513
+ async function tryUpdateBinaries ( binFolder : File , localVer ?: string ) : Promise < boolean > {
498
514
499
515
const eideCfg = ResManager . GetInstance ( ) . getAppConfig < any > ( ) ;
500
516
const minReqVersion = eideCfg [ 'binary_min_version' ] ;
@@ -578,15 +594,12 @@ async function tryUpdateBinaries(binFolder: File, localVer?: string, notConfirm?
578
594
// check bin folder
579
595
// show notify to user and request a confirm
580
596
if ( checkBinFolder ( binFolder ) && preinstallVersion ) {
581
-
582
- if ( ! notConfirm ) {
583
- const msg = `New update for eide binaries, version: '${ preinstallVersion } ', [ChangeLog](https://github.com/github0null/eide-resource/pulls?q=is%3Apr+is%3Aclosed), install now ?` ;
584
- const sel = await vscode . window . showInformationMessage ( msg , 'Yes' , 'Later' ) ;
585
- if ( sel != 'Yes' ) { return true ; } // user canceled
586
- }
587
-
588
- // del old bin folder before install
589
- platform . DeleteDir ( binFolder ) ;
597
+ //TODO
598
+ // if (!notConfirm) {
599
+ // const msg = `New update for eide binaries, version: '${preinstallVersion}', [ChangeLog](https://github.com/github0null/eide-resource/pulls?q=is%3Apr+is%3Aclosed), install now ?`;
600
+ // const sel = await vscode.window.showInformationMessage(msg, 'Yes', 'Later');
601
+ // if (sel != 'Yes') { return true; } // user canceled
602
+ // }
590
603
}
591
604
592
605
return await tryInstallBinaries ( binFolder , preinstallVersion ) ;
@@ -615,9 +628,6 @@ async function tryInstallBinaries(binFolder: File, binVersion: string): Promise<
615
628
try {
616
629
const tmpFile = File . fromArray ( [ os . tmpdir ( ) , `eide-binaries-${ binVersion } .${ binType } ` ] ) ;
617
630
618
- /* make dir */
619
- binFolder . CreateDir ( true ) ;
620
-
621
631
const done = await vscode . window . withProgress ( {
622
632
location : vscode . ProgressLocation . Notification ,
623
633
title : 'Downloading eide binaries' ,
@@ -666,6 +676,15 @@ async function tryInstallBinaries(binFolder: File, binVersion: string): Promise<
666
676
667
677
let prevPercent : number = 0 ;
668
678
679
+ // del old binaries
680
+ if ( binFolder . IsDir ( ) ) {
681
+ progress . report ( { message : `Cleanup old files ...` } ) ;
682
+ platform . DeleteAllChildren ( binFolder ) ;
683
+ }
684
+
685
+ // make dir
686
+ binFolder . CreateDir ( true ) ;
687
+
669
688
// start unzip
670
689
node7z . extractFull ( tmpFile . path , binFolder . path , {
671
690
$bin : ResManager . GetInstance ( ) . Get7za ( ) . path ,
@@ -900,6 +919,9 @@ function exportEnvToSysPath(context?: vscode.ExtensionContext) {
900
919
}
901
920
}
902
921
922
+ /* setup python3 cmd */
923
+ process . env [ 'EIDE_PY3_CMD' ] = resManager . getPython3 ( ) ;
924
+
903
925
// .NET 工具会收集用法数据,帮助我们改善你的体验。它由 Microsoft 收集并与社区共享。
904
926
// 你可通过使用喜欢的 shell 将 DOTNET_CLI_TELEMETRY_OPTOUT 环境变量设置为 "1" 或 "true" 来选择退出遥测。
905
927
// 阅读有关 .NET CLI 工具遥测的更多信息: https://aka.ms/dotnet-cli-telemetry
0 commit comments