diff --git a/src/command/archive/get/file.c b/src/command/archive/get/file.c index c80f65d2a..6fc3a1211 100644 --- a/src/command/archive/get/file.c +++ b/src/command/archive/get/file.c @@ -167,7 +167,7 @@ archiveGetFile( // Copy the file storageCopyNP( storageNewReadP( - storageRepo(), strNewFmt("%s/%s", STORAGE_REPO_ARCHIVE, strPtr(archiveGetCheckResult.archiveFileActual)), + storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s", strPtr(archiveGetCheckResult.archiveFileActual)), .compressible = compressible), destination); diff --git a/src/command/expire/expire.c b/src/command/expire/expire.c index 351ba54e5..6b58155b7 100644 --- a/src/command/expire/expire.c +++ b/src/command/expire/expire.c @@ -274,8 +274,7 @@ removeExpiredArchive(InfoBackup *infoBackup) // Get a list of archive directories (e.g. 9.4-1, 10-2, etc) sorted by the db-id (number after the dash). StringList *listArchiveDisk = strLstSort( strLstComparatorSet( - storageListP( - storageRepo(), STRDEF(STORAGE_REPO_ARCHIVE), .expression = STRDEF(REGEX_ARCHIVE_DIR_DB_VERSION)), + storageListP(storageRepo(), STORAGE_REPO_ARCHIVE_STR, .expression = STRDEF(REGEX_ARCHIVE_DIR_DB_VERSION)), archiveIdComparator), sortOrderAsc); @@ -598,8 +597,8 @@ removeExpiredBackup(InfoBackup *infoBackup) StringList *currentBackupList = strLstSort(infoBackupDataLabelList(infoBackup, NULL), sortOrderDesc); StringList *backupList = strLstSort( storageListP( - storageRepo(), STRDEF(STORAGE_REPO_BACKUP), .expression = backupRegExpP(.full = true, .differential = true, - .incremental = true)), + storageRepo(), STORAGE_REPO_BACKUP_STR, + .expression = backupRegExpP(.full = true, .differential = true, .incremental = true)), sortOrderDesc); // Remove non-current backups from disk diff --git a/src/command/stanza/create.c b/src/command/stanza/create.c index 62843a920..3f2909044 100644 --- a/src/command/stanza/create.c +++ b/src/command/stanza/create.c @@ -57,10 +57,8 @@ cmdStanzaCreate(void) // then create the stanza if (!archiveInfoFileExists && !archiveInfoFileCopyExists && !backupInfoFileExists && !backupInfoFileCopyExists) { - bool archiveNotEmpty = strLstSize( - storageListNP(storageRepoReadStanza, STRDEF(STORAGE_REPO_ARCHIVE))) > 0 ? true : false; - bool backupNotEmpty = strLstSize( - storageListNP(storageRepoReadStanza, STRDEF(STORAGE_REPO_BACKUP))) > 0 ? true : false; + bool archiveNotEmpty = strLstSize(storageListNP(storageRepoReadStanza, STORAGE_REPO_ARCHIVE_STR)) > 0 ? true : false; + bool backupNotEmpty = strLstSize(storageListNP(storageRepoReadStanza, STORAGE_REPO_BACKUP_STR)) > 0 ? true : false; // If something else exists in the backup or archive directories for this stanza, then error if (archiveNotEmpty || backupNotEmpty) diff --git a/src/command/stanza/delete.c b/src/command/stanza/delete.c index d3ce00688..eae893f9b 100644 --- a/src/command/stanza/delete.c +++ b/src/command/stanza/delete.c @@ -31,8 +31,10 @@ manifestDelete(const Storage *storageRepoWriteStanza) // Get the list of backup directories from newest to oldest since don't want to invalidate a backup before // invalidating any backups that depend on it. StringList *backupList = strLstSort( - storageListP(storageRepo(), STRDEF(STORAGE_REPO_BACKUP), .expression = backupRegExpP(.full = true, - .differential = true, .incremental = true)), sortOrderDesc); + storageListP( + storageRepo(), STORAGE_REPO_BACKUP_STR, + .expression = backupRegExpP(.full = true, .differential = true, .incremental = true)), + sortOrderDesc); // Delete all manifest files for (unsigned int idx = 0; idx < strLstSize(backupList); idx++) @@ -108,10 +110,10 @@ stanzaDelete(const Storage *storageRepoWriteStanza, const StringList *archiveLis // Recursively remove the entire stanza repo if exists. S3 will attempt to remove even if not. if (archiveList != NULL) - storagePathRemoveP(storageRepoWriteStanza, STRDEF(STORAGE_REPO_ARCHIVE), .recurse = true); + storagePathRemoveP(storageRepoWriteStanza, STORAGE_REPO_ARCHIVE_STR, .recurse = true); if (backupList != NULL) - storagePathRemoveP(storageRepoWriteStanza, STRDEF(STORAGE_REPO_BACKUP), .recurse = true); + storagePathRemoveP(storageRepoWriteStanza, STORAGE_REPO_BACKUP_STR, .recurse = true); // Remove the stop file - this will not error if the stop file does not exist. If the stanza directories existed but nothing // was in them, then no pgbackrest commands can be in progress without the info files so a stop is technically not necessary @@ -141,9 +143,8 @@ cmdStanzaDelete(void) const Storage *storageRepoReadStanza = storageRepo(); stanzaDelete( - storageRepoWrite(), - storageListP(storageRepoReadStanza, STRDEF(STORAGE_REPO_ARCHIVE), .nullOnMissing = true), - storageListP(storageRepoReadStanza, STRDEF(STORAGE_REPO_BACKUP), .nullOnMissing = true)); + storageRepoWrite(), storageListP(storageRepoReadStanza, STORAGE_REPO_ARCHIVE_STR, .nullOnMissing = true), + storageListP(storageRepoReadStanza, STORAGE_REPO_BACKUP_STR, .nullOnMissing = true)); } MEM_CONTEXT_TEMP_END(); diff --git a/src/info/infoBackup.c b/src/info/infoBackup.c index 0adbdedd2..2113d93a1 100644 --- a/src/info/infoBackup.c +++ b/src/info/infoBackup.c @@ -634,8 +634,8 @@ infoBackupLoadFileReconstruct(const Storage *storage, const String *fileName, Ci // Get a list of backups in the repo StringList *backupList = strLstSort( storageListP( - storage, STRDEF(STORAGE_REPO_BACKUP), .expression = backupRegExpP(.full = true, .differential = true, - .incremental = true)), + storage, STORAGE_REPO_BACKUP_STR, + .expression = backupRegExpP(.full = true, .differential = true, .incremental = true)), sortOrderAsc); // Get the current list of backups from backup.info diff --git a/src/storage/helper.c b/src/storage/helper.c index d28bddd0e..9e40d6d38 100644 --- a/src/storage/helper.c +++ b/src/storage/helper.c @@ -23,6 +23,9 @@ Storage path constants STRING_EXTERN(STORAGE_SPOOL_ARCHIVE_IN_STR, STORAGE_SPOOL_ARCHIVE_IN); STRING_EXTERN(STORAGE_SPOOL_ARCHIVE_OUT_STR, STORAGE_SPOOL_ARCHIVE_OUT); +STRING_EXTERN(STORAGE_REPO_ARCHIVE_STR, STORAGE_REPO_ARCHIVE); +STRING_EXTERN(STORAGE_REPO_BACKUP_STR, STORAGE_REPO_BACKUP); + STRING_EXTERN(STORAGE_PATH_ARCHIVE_STR, STORAGE_PATH_ARCHIVE); STRING_EXTERN(STORAGE_PATH_BACKUP_STR, STORAGE_PATH_BACKUP); @@ -278,7 +281,7 @@ storageRepoPathExpression(const String *expression, const String *path) String *result = NULL; - if (strEqZ(expression, STORAGE_REPO_ARCHIVE)) + if (strEq(expression, STORAGE_REPO_ARCHIVE_STR)) { // Construct the base path if (storageHelper.stanza != NULL) @@ -298,7 +301,7 @@ storageRepoPathExpression(const String *expression, const String *path) strCatFmt(result, "/%s", strPtr(path)); } } - else if (strEqZ(expression, STORAGE_REPO_BACKUP)) + else if (strEq(expression, STORAGE_REPO_BACKUP_STR)) { // Construct the base path if (storageHelper.stanza != NULL) diff --git a/src/storage/helper.h b/src/storage/helper.h index 1e5324293..e46d3c36e 100644 --- a/src/storage/helper.h +++ b/src/storage/helper.h @@ -15,7 +15,9 @@ Storage path constants STRING_DECLARE(STORAGE_SPOOL_ARCHIVE_OUT_STR); #define STORAGE_REPO_ARCHIVE "" + STRING_DECLARE(STORAGE_REPO_ARCHIVE_STR); #define STORAGE_REPO_BACKUP "" + STRING_DECLARE(STORAGE_REPO_BACKUP_STR); #define STORAGE_PATH_ARCHIVE "archive" STRING_DECLARE(STORAGE_PATH_ARCHIVE_STR); diff --git a/test/src/module/info/infoBackupTest.c b/test/src/module/info/infoBackupTest.c index 2885c0482..1c15bf5e7 100644 --- a/test/src/module/info/infoBackupTest.c +++ b/test/src/module/info/infoBackupTest.c @@ -669,7 +669,7 @@ testRun(void) "create backup on disk that is in current but no manifest"); TEST_RESULT_STR( - strPtr(strLstJoin(strLstSort(storageListP(storageRepo(), STRDEF(STORAGE_REPO_BACKUP), + strPtr(strLstJoin(strLstSort(storageListP(storageRepo(), STORAGE_REPO_BACKUP_STR, .expression = backupRegExpP(.full = true, .differential = true, .incremental = true)), sortOrderAsc), ", ")), "20190818-084444F, 20190818-084502F, 20190818-084555F, 20190818-084666F, 20190818-084777F, 20190923-164324F", "confirm backups on disk"); diff --git a/test/src/module/storage/posixTest.c b/test/src/module/storage/posixTest.c index 1eac05c81..c4d758a07 100644 --- a/test/src/module/storage/posixTest.c +++ b/test/src/module/storage/posixTest.c @@ -1079,7 +1079,7 @@ testRun(void) TEST_RESULT_STR(strPtr(storagePathNP(storage, NULL)), testPath(), "check base path"); TEST_RESULT_STR( - strPtr(storagePathNP(storage, strNew(STORAGE_REPO_ARCHIVE))), strPtr(strNewFmt("%s/archive/db", testPath())), + strPtr(storagePathNP(storage, STORAGE_REPO_ARCHIVE_STR)), strPtr(strNewFmt("%s/archive/db", testPath())), "check archive path"); TEST_RESULT_STR( strPtr(storagePathNP(storage, strNew(STORAGE_REPO_ARCHIVE "/simple"))), @@ -1095,7 +1095,7 @@ testRun(void) strPtr(strNewFmt("%s/archive/db/9.4-1/000000010000014C/000000010000014C0000001A.00000028.backup", testPath())), "check archive backup path"); TEST_RESULT_STR( - strPtr(storagePathNP(storage, strNew(STORAGE_REPO_BACKUP))), strPtr(strNewFmt("%s/backup/db", testPath())), + strPtr(storagePathNP(storage, STORAGE_REPO_BACKUP_STR)), strPtr(strNewFmt("%s/backup/db", testPath())), "check backup path"); // Change the stanza to NULL with the stanzaInit flag still true, make sure helper does not fail when stanza option not set @@ -1108,13 +1108,13 @@ testRun(void) TEST_RESULT_PTR(storageHelper.stanza, NULL, "stanza NULL"); TEST_RESULT_STR( - strPtr(storagePathNP(storage, strNew(STORAGE_REPO_ARCHIVE))), strPtr(strNewFmt("%s/archive", testPath())), + strPtr(storagePathNP(storage, STORAGE_REPO_ARCHIVE_STR)), strPtr(strNewFmt("%s/archive", testPath())), "check archive path - NULL stanza"); TEST_RESULT_STR( strPtr(storagePathNP(storage, strNew(STORAGE_REPO_ARCHIVE "/simple"))), strPtr(strNewFmt("%s/archive/simple", testPath())), "check simple archive path - NULL stanza"); TEST_RESULT_STR( - strPtr(storagePathNP(storage, strNew(STORAGE_REPO_BACKUP))), strPtr(strNewFmt("%s/backup", testPath())), + strPtr(storagePathNP(storage, STORAGE_REPO_BACKUP_STR)), strPtr(strNewFmt("%s/backup", testPath())), "check backup path - NULL stanza"); TEST_RESULT_STR( strPtr(storagePathNP(storage, strNew(STORAGE_REPO_BACKUP "/simple"))),