1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-04-17 11:46:39 +02:00

Simplify filename construction in command/verify module.

Remove some duplicated code by tracking the backup label and constructing the filename only when needed.
This commit is contained in:
David Steele 2022-02-04 12:48:50 -06:00
parent b1da4e84e8
commit 7dd657b7dd
2 changed files with 12 additions and 15 deletions

View File

@ -71,6 +71,7 @@
<commit subject="Pack manifest file structs to save memory."/>
<commit subject="Optimization for jsonFromStrInternal()."/>
<commit subject="Simplify manifest file defaults."/>
<commit subject="Simplify filename construction in command/verify module."/>
<release-item-contributor-list>
<release-item-contributor id="david.steele"/>

View File

@ -904,12 +904,12 @@ verifyBackup(void *data)
{
const ManifestFile fileData = manifestFile(jobData->manifest, jobData->manifestFileIdx);
String *filePathName = NULL;
// Track the files verified in order to determine when the processing of the backup is complete
backupResult->totalFileVerify++;
// Check if the file is referenced in a prior backup
const String *fileBackupLabel = NULL;
if (fileData.reference != NULL)
{
// If the prior backup is not in the result list, then that backup was never processed (likely due to the --set
@ -918,9 +918,7 @@ verifyBackup(void *data)
if (backupPriorIdx == LIST_NOT_FOUND)
{
filePathName = strNewFmt(
STORAGE_REPO_BACKUP "/%s/%s%s", strZ(fileData.reference), strZ(fileData.name),
strZ(compressExtStr((manifestData(jobData->manifest))->backupOptionCompressType)));
fileBackupLabel = fileData.reference;
}
// Else the backup this file references has a result so check the processing state for the referenced backup
else
@ -930,9 +928,7 @@ verifyBackup(void *data)
// If the verify-state of the backup is not complete then verify the file
if (!backupResultPrior->fileVerifyComplete)
{
filePathName = strNewFmt(
STORAGE_REPO_BACKUP "/%s/%s%s", strZ(fileData.reference), strZ(fileData.name),
strZ(compressExtStr((manifestData(jobData->manifest))->backupOptionCompressType)));
fileBackupLabel = fileData.reference;
}
// Else skip verification
else
@ -963,19 +959,19 @@ verifyBackup(void *data)
}
// Else file is not referenced in a prior backup
else
{
filePathName = strNewFmt(
STORAGE_REPO_BACKUP "/%s/%s%s", strZ(backupResult->backupLabel), strZ(fileData.name),
strZ(compressExtStr((manifestData(jobData->manifest))->backupOptionCompressType)));
}
fileBackupLabel = backupResult->backupLabel;
// If constructed file name is not null then send it off for processing
if (filePathName != NULL)
// If backup label is not null then send it off for processing
if (fileBackupLabel != NULL)
{
// Set up the job
ProtocolCommand *command = protocolCommandNew(PROTOCOL_COMMAND_VERIFY_FILE);
PackWrite *const param = protocolCommandParam(command);
const String *const filePathName = strNewFmt(
STORAGE_REPO_BACKUP "/%s/%s%s", strZ(fileBackupLabel), strZ(fileData.name),
strZ(compressExtStr((manifestData(jobData->manifest))->backupOptionCompressType)));
pckWriteStrP(param, filePathName);
// If the checksum is not present in the manifest, it will be calculated by manifest load
pckWriteStrP(param, STR(fileData.checksumSha1));