@@ -172,17 +172,22 @@ private bool OutputContinueGameJson(Configuration config) {
172172 // Set the current save to be used when launching the game with the continuelastsave option.
173173 Logger . Debug ( "Modifying continue_game.json..." ) ;
174174 var continueGamePath = Path . Join ( config . ImperatorDocPath , "continue_game.json" ) ;
175-
175+ var continueGameBackupPath = continueGamePath + ".backup" ;
176+
176177 // Backup the original file if it exists
177178 if ( File . Exists ( continueGamePath ) ) {
178179 try {
179- FileHelper . MoveWithRetries ( continueGamePath , continueGamePath + ".backup" ) ;
180+ if ( File . Exists ( continueGameBackupPath ) ) {
181+ File . SetAttributes ( continueGameBackupPath , FileAttributes . Normal ) ;
182+ FileHelper . DeleteWithRetries ( continueGameBackupPath ) ;
183+ }
184+ FileHelper . MoveWithRetries ( continueGamePath , continueGameBackupPath ) ;
180185 } catch ( Exception ex ) {
181186 Logger . Debug ( $ "Failed to backup continue_game.json: { ex . Message } ") ;
182187 return false ;
183188 }
184189 }
185-
190+
186191 return TryWriteTextFile ( continueGamePath ,
187192 contents : $$ """
188193 {
@@ -196,11 +201,16 @@ private bool OutputContinueGameJson(Configuration config) {
196201 private bool OutputDlcLoadJson ( Configuration config ) {
197202 Logger . Debug ( "Outputting dlc_load.json..." ) ;
198203 var dlcLoadPath = Path . Join ( config . ImperatorDocPath , "dlc_load.json" ) ;
204+ var dlcLoadBackupPath = dlcLoadPath + ".backup" ;
199205
200206 // Backup the original file if it exists
201207 if ( File . Exists ( dlcLoadPath ) ) {
202208 try {
203- FileHelper . MoveWithRetries ( dlcLoadPath , dlcLoadPath + ".backup" ) ;
209+ if ( File . Exists ( dlcLoadBackupPath ) ) {
210+ File . SetAttributes ( dlcLoadBackupPath , FileAttributes . Normal ) ;
211+ FileHelper . DeleteWithRetries ( dlcLoadBackupPath ) ;
212+ }
213+ FileHelper . MoveWithRetries ( dlcLoadPath , dlcLoadBackupPath ) ;
204214 } catch ( Exception ex ) {
205215 Logger . Debug ( $ "Failed to backup dlc_load.json: { ex . Message } ") ;
206216 return false ;
0 commit comments