pgbackrest.git / summary / log / commit / refs
commit 7dd657b7dd163ded9fbf7caef37eea7e08bc5a37
Author: David Steele <david@pgmasters.net>
Date: Fri Feb 04 18:48:50 2022 +0000
Simplify filename construction in command/verify module.
Remove some duplicated code by tracking the backup label and constructing the filename only when needed.
doc/xml/release.xml | 1 +
src/command/verify/verify.c | 26 +++++++++++---------------
2 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/doc/xml/release.xml b/doc/xml/release.xml
index 12f8f8283..4dd9a7b29 100644
--- a/doc/xml/release.xml
+++ b/doc/xml/release.xml
@@ -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"/>
diff --git a/src/command/verify/verify.c b/src/command/verify/verify.c
index bd1b0f431..8693788e6 100644
--- a/src/command/verify/verify.c
+++ b/src/command/verify/verify.c
@@ -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));
[parent: b1da4e84e8b1]