@@ -694,7 +694,7 @@ static int RunInstall()
694
694
bool backupExists = FileExists (file.backupFile .absolutePath );
695
695
uint64_t backupSize = FileSize (file.backupFile .absolutePath );
696
696
AddReportLog (5055 , SString (" RunInstall: Unable to create backup of '%s' (attempts: %d, checksums: %d, target: %d [size:%llu hash:%08x], backup: %d "
697
- " [size: %llu hash:%08x])" ,
697
+ " [size:%llu hash:%08x])" ,
698
698
file.relativePath .c_str (), attempts, checksums, targetExists, targetSize, file.targetFile .checksum .value_or (0 ),
699
699
backupExists, backupSize, file.backupFile .checksum .value_or (0 )));
700
700
return 6 ;
@@ -828,6 +828,13 @@ static int RunInstall()
828
828
}
829
829
830
830
OutputDebugLine (SString (" RunInstall: Installation of %zu files complete" , files.size ()));
831
+
832
+ // Switch to the source directory's parent to finally delete the source directory.
833
+ if (SetCurrentDirectory (ExtractPath (sourceRoot)))
834
+ {
835
+ DirectoryDeleteScope deleteSourceRoot (sourceRoot);
836
+ }
837
+
831
838
return 0 ;
832
839
}
833
840
@@ -903,6 +910,8 @@ SString CheckOnRestartCommand()
903
910
if (sourceRoot.empty ())
904
911
return " FileError1" ;
905
912
913
+ DirectoryDeleteScope deleteSourceRoot (sourceRoot);
914
+
906
915
if (!SetCurrentDirectory (sourceRoot))
907
916
return " FileError2" ;
908
917
@@ -911,13 +920,20 @@ SString CheckOnRestartCommand()
911
920
StartPseudoProgress (g_hInstance, " MTA: San Andreas" , _ (" Extracting files..." ));
912
921
913
922
// Try to extract the files
914
- if (!ExtractFiles (strFile, true ))
923
+ bool success = ExtractFiles (strFile, /* withManifest */ true );
924
+
925
+ if (!success)
915
926
{
916
927
// If extract failed and update file is an .exe or .msu, try to run it
917
928
if (ExtractExtension (strFile).EqualsI (" exe" ) || ExtractExtension (strFile).EqualsI (" msu" ))
918
- ShellExecuteBlocking (" open" , strFile, strParameters.SplitRight (" ###" ));
929
+ success = ShellExecuteBlocking (" open" , strFile, strParameters.SplitRight (" ###" ));
919
930
}
920
931
932
+ if (!success)
933
+ return " FileError3" ;
934
+
935
+ deleteSourceRoot.Release ();
936
+
921
937
// Stop progress bar
922
938
StopPseudoProgress ();
923
939
0 commit comments