File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,10 +30,20 @@ public Form1()
3030 // ensure the existance of the necessary config file
3131 if ( ! File . Exists ( NameAssociations . configManifestPath ) )
3232 {
33- // file not found
34- // typically at the first usage of the program
35- // create an empty config file
36- NameAssociations . CreateEmptyConfigFile ( ) ;
33+ // the manifest file hasn't been found…
34+ if ( File . Exists ( NameAssociations . legacyConfigPath ) )
35+ {
36+ // … but there is a legacy config file
37+ // that means that we need to convert a `v1` config file
38+ NameAssociations . checkAndUpgradeConfigurationFile ( true ) ;
39+ }
40+ else
41+ {
42+ // file not found
43+ // typically at the first usage of the program
44+ // create an empty config file
45+ NameAssociations . CreateEmptyConfigFile ( ) ;
46+ }
3747 }
3848 else
3949 {
Original file line number Diff line number Diff line change @@ -37,7 +37,12 @@ public static string GetConfigFilePath()
3737 ".json" ;
3838 }
3939
40- public static void checkAndUpgradeConfigurationFile ( ) {
40+ public static void checkAndUpgradeConfigurationFile ( bool isV1 = false ) {
41+ if ( isV1 == true )
42+ {
43+ File . WriteAllText ( configManifestPath , "v1" ) ;
44+ }
45+
4146 string manifestVersion = File . ReadAllText ( Path . GetFullPath ( configManifestPath ) ) ;
4247
4348 if ( ! File . Exists ( Path . GetFullPath ( GetConfigFilePath ( ) ) ) )
@@ -62,6 +67,7 @@ public static void checkAndUpgradeConfigurationFile() {
6267 } ) ;
6368 }
6469
70+ File . WriteAllText ( configManifestPath , "v2" ) ;
6571 WriteByList ( convertedValues ) ;
6672 }
6773 }
You can’t perform that action at this time.
0 commit comments