@@ -214,12 +214,17 @@ export class CodeSync {
214214
215215 exportSettings ( ) : void {
216216 if ( this . Settings . Settings . importSettings ) {
217+ this . logger . appendLine ( 'Exporting settings.' ) ;
217218 this . startSync ( 'Exporting settings' ) ;
218- if ( ! fs . existsSync ( helpers . getUserSettingsFilePath ( ) ) ) {
219+ let settingsPath : string = helpers . getUserSettingsFilePath ( ) ;
220+ if ( ! fs . existsSync ( settingsPath ) ) {
221+ this . logger . appendLine ( `Could not find settings path at ${ settingsPath } . Giving up.` ) ;
222+ this . statusBar . reset ( ) ;
219223 return ;
220224 }
221225 this . localSettingsManager . export ( helpers . getUserSettingsFilePath ( ) , path . join ( this . codeSyncDir , SETTINGS ) ) ;
222226 this . statusBar . reset ( ) ;
227+ this . logger . appendLine ( 'Finished exporting settings.' ) ;
223228 }
224229 }
225230
@@ -555,15 +560,24 @@ export class CodeSync {
555560 let tmpExtension = helpers . getFolderExtensionInfo ( f ) ;
556561 if ( tmpExtension . id == 'golf1052.code-sync' ) {
557562 if ( tmpExtension . id == 'golf1052.code-sync' && helpers . isVersionGreaterThan ( currentVersion , tmpExtension . version ) == 1 ) {
558- this . logger . appendLine ( `Migrating stuff. Previous version: ${ tmpExtension . version } . Current version: ${ currentVersion } .` ) ;
559- if ( fs . existsSync ( path . join ( this . vsCodeExtensionDir , f , SETTINGS ) ) ) {
563+ // When the extension is updated we migrate settings to the new extension folder before trying to create settings.
564+ // So if the settings files already exist we've migrated them already and we don't need to migrate them again.
565+ // We don't migrate them again so we don't overwrite any new changes in the new settings files.
566+ let settingsExists : boolean = fs . existsSync ( path . join ( codeSyncExtensionDir , SETTINGS ) ) ;
567+ let localSettingsExists : boolean = fs . existsSync ( path . join ( codeSyncExtensionDir , LOCAL_SETTINGS ) ) ;
568+ if ( ! settingsExists || ! localSettingsExists ) {
569+ this . logger . appendLine ( `Migrating stuff. Previous version: ${ tmpExtension . version } . Current version: ${ currentVersion } .` ) ;
570+ } else {
571+ this . logger . appendLine ( `All settings files already exist. Not migrating. Previous version: ${ tmpExtension . version } . Current version: ${ currentVersion } .` ) ;
572+ }
573+ if ( fs . existsSync ( path . join ( this . vsCodeExtensionDir , f , SETTINGS ) ) && ! settingsExists ) {
560574 this . logger . appendLine ( `Migrating settings.` ) ;
561575 let oldSettings = path . join ( this . vsCodeExtensionDir , f , SETTINGS ) ;
562576 let newSettings = path . join ( codeSyncExtensionDir , SETTINGS ) ;
563577 this . logger . appendLine ( `Previous file: ${ oldSettings } . New file: ${ newSettings } .` )
564578 await helpers . copy ( oldSettings , newSettings ) ;
565579 }
566- if ( fs . existsSync ( path . join ( this . vsCodeExtensionDir , f , LOCAL_SETTINGS ) ) ) {
580+ if ( fs . existsSync ( path . join ( this . vsCodeExtensionDir , f , LOCAL_SETTINGS ) ) && ! localSettingsExists ) {
567581 this . logger . appendLine ( `Migrating local settings.` ) ;
568582 let oldLocalSettings = path . join ( this . vsCodeExtensionDir , f , LOCAL_SETTINGS ) ;
569583 let newLocalSettings = path . join ( codeSyncExtensionDir , LOCAL_SETTINGS ) ;
0 commit comments