mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-12 10:04:14 +02:00
Allow end anchor to be excluded in backupRegExp().
This is useful for matching files in the backup history directory which have characters after the backup label.
This commit is contained in:
parent
8acfb6adf4
commit
e206093beb
@ -26,6 +26,7 @@ backupRegExp(BackupRegExpParam param)
|
||||
FUNCTION_LOG_PARAM(BOOL, param.full);
|
||||
FUNCTION_LOG_PARAM(BOOL, param.differential);
|
||||
FUNCTION_LOG_PARAM(BOOL, param.incremental);
|
||||
FUNCTION_LOG_PARAM(BOOL, param.noAnchorEnd);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(param.full || param.differential || param.incremental);
|
||||
@ -76,7 +77,8 @@ backupRegExp(BackupRegExpParam param)
|
||||
}
|
||||
|
||||
// Append the end anchor
|
||||
strCat(result, "$");
|
||||
if (!param.noAnchorEnd)
|
||||
strCat(result, "$");
|
||||
|
||||
FUNCTION_LOG_RETURN(STRING, result);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ typedef struct BackupRegExpParam
|
||||
bool full;
|
||||
bool differential;
|
||||
bool incremental;
|
||||
bool noAnchorEnd;
|
||||
} BackupRegExpParam;
|
||||
|
||||
#define backupRegExpP(...) \
|
||||
|
@ -90,17 +90,14 @@ testRun(void)
|
||||
TEST_RESULT_BOOL(regExpMatchOne(filter, full), true, " match full");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
filter = backupRegExpP(.incremental = true, .differential = true);
|
||||
filter = backupRegExpP(.incremental = true, .differential = true, .noAnchorEnd = true);
|
||||
|
||||
TEST_RESULT_STR(
|
||||
strPtr(filter),
|
||||
"^[0-9]{8}\\-[0-9]{6}F\\_[0-9]{8}\\-[0-9]{6}(D|I)$", "diff and incr backup regex with anchors");
|
||||
"^[0-9]{8}\\-[0-9]{6}F\\_[0-9]{8}\\-[0-9]{6}(D|I)", "diff and incr backup regex with anchors");
|
||||
TEST_RESULT_BOOL(regExpMatchOne(filter, incr), true, " match incr");
|
||||
TEST_RESULT_BOOL(regExpMatchOne(filter, diff), true, " match diff");
|
||||
TEST_RESULT_BOOL(regExpMatchOne(filter, full), false, " does not match full");
|
||||
TEST_RESULT_BOOL(
|
||||
regExpMatchOne(
|
||||
filter, strNew("12341234-123123F_12341234-123123DG")), false, " does not match with trailing character");
|
||||
TEST_RESULT_BOOL(
|
||||
regExpMatchOne(
|
||||
filter, strNew("A12341234-123123F_12341234-123123I")), false, " does not match with leading character");
|
||||
|
Loading…
Reference in New Issue
Block a user