diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 5defd48fc..c34678a56 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -104,7 +104,7 @@ -

Allow NULL stanza in storage helper.

+

Storage helper improvements. Allow NULL stanza in storage helper. Add path expression for repository backup.

diff --git a/src/storage/helper.c b/src/storage/helper.c index bf111632c..db52960d6 100644 --- a/src/storage/helper.c +++ b/src/storage/helper.c @@ -18,6 +18,7 @@ STRING_EXTERN(STORAGE_SPOOL_ARCHIVE_IN_STR, STORAGE_SPOO STRING_EXTERN(STORAGE_SPOOL_ARCHIVE_OUT_STR, STORAGE_SPOOL_ARCHIVE_OUT); #define STORAGE_PATH_ARCHIVE "archive" +#define STORAGE_PATH_BACKUP "backup" /*********************************************************************************************************************************** Local variables @@ -173,6 +174,18 @@ storageRepoPathExpression(const String *expression, const String *path) strCatFmt(result, "/%s", strPtr(path)); } } + else if (strEqZ(expression, STORAGE_REPO_BACKUP)) + { + // Contruct the base path + if (storageHelper.stanza != NULL) + result = strNewFmt(STORAGE_PATH_BACKUP "/%s", strPtr(storageHelper.stanza)); + else + result = strNew(STORAGE_PATH_BACKUP); + + // Append subpath if provided + if (path != NULL) + strCatFmt(result, "/%s", strPtr(path)); + } else THROW_FMT(AssertError, "invalid expression '%s'", strPtr(expression)); diff --git a/src/storage/helper.h b/src/storage/helper.h index 8bf956296..83cc0267b 100644 --- a/src/storage/helper.h +++ b/src/storage/helper.h @@ -15,6 +15,7 @@ Storage path constants STRING_DECLARE(STORAGE_SPOOL_ARCHIVE_OUT_STR); #define STORAGE_REPO_ARCHIVE "" +#define STORAGE_REPO_BACKUP "" /*********************************************************************************************************************************** Repository storage types diff --git a/test/src/module/storage/posixTest.c b/test/src/module/storage/posixTest.c index 7119e87b5..f98c4b485 100644 --- a/test/src/module/storage/posixTest.c +++ b/test/src/module/storage/posixTest.c @@ -962,6 +962,9 @@ testRun(void) strPtr(storagePathNP(storage, strNew(STORAGE_REPO_ARCHIVE "/9.4-1/000000010000014C0000001A.00000028.backup"))), 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())), + "check backup path"); // Change the stanza name and make sure helper fails // ------------------------------------------------------------------------------------------------------------------------- @@ -1012,6 +1015,12 @@ testRun(void) 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())), + "check backup path - NULL stanza"); + TEST_RESULT_STR( + strPtr(storagePathNP(storage, strNew(STORAGE_REPO_BACKUP "/simple"))), + strPtr(strNewFmt("%s/backup/simple", testPath())), "check simple backup path - NULL stanza"); // Reset init flag storageHelper.stanzaInit = false;