18
18
static std::string ROLLBACK_NAME = " rollback.step" ;
19
19
static char ARCHIVE_PASSWORD[] = " mta" ;
20
20
21
+ constexpr DWORD OPERATION_RETRY_DELAY_IN_MS = 100 ;
22
+
21
23
struct ChecksumFile
22
24
{
23
25
std::optional<uint32_t > checksum{};
@@ -410,6 +412,9 @@ static auto RunRollback(std::vector<InstallableFile>& files) -> size_t
410
412
411
413
for (InstallableFile& file : files)
412
414
{
415
+ if (file.targetFile == file.backupFile )
416
+ continue ;
417
+
413
418
int attempts = 0 ;
414
419
int checksums = 0 ;
415
420
bool success = false ;
@@ -447,8 +452,7 @@ static auto RunRollback(std::vector<InstallableFile>& files) -> size_t
447
452
TerminateFileLockingProcesses (file.backupFile .absolutePath , file.relativePath );
448
453
}
449
454
450
- // Wait for an arbitrary amount of time before retrying.
451
- Sleep (100 );
455
+ Sleep (OPERATION_RETRY_DELAY_IN_MS);
452
456
}
453
457
}
454
458
@@ -686,8 +690,7 @@ static int RunInstall()
686
690
TerminateFileLockingProcesses (file.backupFile .absolutePath , file.relativePath );
687
691
}
688
692
689
- // Wait for an arbitrary amount of time before retrying.
690
- Sleep (100 );
693
+ Sleep (OPERATION_RETRY_DELAY_IN_MS);
691
694
}
692
695
}
693
696
@@ -760,8 +763,7 @@ static int RunInstall()
760
763
TerminateFileLockingProcesses (file.sourceFile .absolutePath , file.relativePath );
761
764
}
762
765
763
- // Wait for an arbitrary amount of time before retrying.
764
- Sleep (100 );
766
+ Sleep (OPERATION_RETRY_DELAY_IN_MS);
765
767
}
766
768
}
767
769
@@ -778,6 +780,9 @@ static int RunInstall()
778
780
779
781
if (!success)
780
782
{
783
+ // Update the target file checksum for rollback, because we don't know if the target file was modified in the install process.
784
+ file.targetFile .ComputeChecksum ();
785
+
781
786
bool exists = FileExists (file.sourceFile .absolutePath );
782
787
AddReportLog (5055 , SString (" RunInstall: Unable to install '%s' (exists: %d, attempts: %d, checksums: %d)" , file.relativePath .c_str (), exists,
783
788
attempts, checksums));
@@ -866,6 +871,9 @@ bool InstallFiles(bool showProgressWindow)
866
871
867
872
bool ExtractFiles (const std::string& archivePath, bool withManifest)
868
873
{
874
+ if (archivePath.empty () || !FileExists (archivePath))
875
+ return false ;
876
+
869
877
std::vector<ManifestFile> files;
870
878
871
879
if (!ExtractArchiveFiles (archivePath, files, ARCHIVE_PASSWORD))
@@ -905,6 +913,9 @@ SString CheckOnRestartCommand()
905
913
// Update
906
914
//
907
915
916
+ if (strFile.empty () || !FileExists (strFile))
917
+ return " FileMissing" ;
918
+
908
919
// Make temp path name and go there
909
920
SString strArchivePath, strArchiveName;
910
921
strFile.Split (" \\ " , &strArchivePath, &strArchiveName, -1 );
0 commit comments