Skip to content

Commit 2c6f097

Browse files
committed
Improve logging for update installer
1 parent 541b2bb commit 2c6f097

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

Client/loader/Install.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,6 @@ static auto RunRollback(std::vector<InstallableFile>& files) -> size_t
435435
AddReportLog(5055, SString("RunRollback: Rollback failed for %zu out of %zu files", disasterCounter, files.size()));
436436
OutputDebugLine(SString("RunRollback: Rollback failed for %zu out of %zu files", disasterCounter, files.size()));
437437
}
438-
else
439-
{
440-
AddReportLog(5055, SString("RunRollback: Rollback succeeded for %zu files", files.size()));
441-
OutputDebugLine(SString("RunRollback: Rollback succeeded for %zu files", files.size()));
442-
}
443438

444439
return disasterCounter;
445440
}
@@ -585,10 +580,7 @@ static int RunInstall()
585580
OutputDebugLine(SString("RunInstall: Installing %zu out of %zu files", files.size(), archiveFiles.size()));
586581

587582
if (files.empty())
588-
{
589-
AddReportLog(5055, SString("RunInstall: Update is obsolete (%zu files skipped)", archiveFiles.size()));
590583
return 0;
591-
}
592584

593585
// Check if any executable or library is locked by any process and terminate it with the user's consent.
594586
for (const InstallableFile& file : files)
@@ -633,6 +625,12 @@ static int RunInstall()
633625

634626
if (!success)
635627
{
628+
if (!FileExists(file.targetFile.absolutePath))
629+
{
630+
AddReportLog(5055, SString("RunInstall: Target file '%s' is missing (attempts: %d)", file.relativePath.c_str(), attempts));
631+
break;
632+
}
633+
636634
if (attempts == 1)
637635
{
638636
// If the first attempt didn't work, check if any process is locking one of the files.
@@ -647,9 +645,14 @@ static int RunInstall()
647645

648646
if (!success)
649647
{
650-
bool exists = FileExists(file.targetFile.absolutePath);
651-
AddReportLog(5055, SString("RunInstall: Unable to create backup of '%s' in '%s' (exists: %d, attempts: %d, checksums: %d)",
652-
file.targetFile.c_str(), file.backupFile.c_str(), exists, attempts, checksums));
648+
bool targetExists = FileExists(file.targetFile.absolutePath);
649+
uint64_t targetSize = FileSize(file.targetFile.absolutePath);
650+
bool backupExists = FileExists(file.backupFile.absolutePath);
651+
uint64_t backupSize = FileSize(file.backupFile.absolutePath);
652+
AddReportLog(5055, SString("RunInstall: Unable to create backup of '%s' (attempts: %d, checksums: %d, target: %d [size:%llu hash:%08x], backup: %d "
653+
"[size: %llu hash:%08x])",
654+
file.relativePath.c_str(), attempts, checksums, targetExists, targetSize, file.targetFile.checksum.value_or(0),
655+
backupExists, backupSize, file.backupFile.checksum.value_or(0)));
653656
return 6;
654657
}
655658
}
@@ -696,6 +699,12 @@ static int RunInstall()
696699

697700
if (!success)
698701
{
702+
if (!FileExists(file.sourceFile.absolutePath))
703+
{
704+
AddReportLog(5055, SString("RunInstall: Source file '%s' is missing (attempts: %d)", file.relativePath.c_str(), attempts));
705+
break;
706+
}
707+
699708
if (attempts == 1)
700709
{
701710
// If the first attempt didn't work, check if any process is locking one of the files.
@@ -722,8 +731,8 @@ static int RunInstall()
722731
if (!success)
723732
{
724733
bool exists = FileExists(file.sourceFile.absolutePath);
725-
AddReportLog(5055, SString("RunInstall: Unable to install '%s' to '%s' (exists: %d, attempts: %d, checksums: %d)", file.sourceFile.c_str(),
726-
file.targetFile.c_str(), exists, attempts, checksums));
734+
AddReportLog(5055, SString("RunInstall: Unable to install '%s' (exists: %d, attempts: %d, checksums: %d)", file.relativePath.c_str(), exists,
735+
attempts, checksums));
727736
requiresRollback = true;
728737
break;
729738
}

0 commit comments

Comments
 (0)