mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
Fix walPath() when CWD is / and path is relative.
The function would return a // prefix in this case, which works fine but looks odd while debugging.
This commit is contained in:
parent
0c05df4582
commit
381aecae4e
@ -247,7 +247,7 @@ walPath(const String *walFile)
|
||||
char currentWorkDir[4096];
|
||||
|
||||
THROW_ON_SYS_ERROR(getcwd(currentWorkDir, sizeof(currentWorkDir)) == NULL, FormatError, "unable to get cwd");
|
||||
result = strNewFmt("%s/%s", currentWorkDir, strPtr(walFile));
|
||||
result = strNewFmt("%s/%s", strcmp(currentWorkDir, "/") != 0 ? currentWorkDir : "", strPtr(walFile));
|
||||
}
|
||||
else
|
||||
result = strDup(walFile);
|
||||
|
@ -176,6 +176,10 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_STR(strPtr(walPath(strNew("/absolute/path"))), "/absolute/path", "absolute path");
|
||||
TEST_RESULT_STR(strPtr(walPath(strNew("relative/path"))), "/tmp/relative/path", "relative path");
|
||||
|
||||
THROW_ON_SYS_ERROR(chdir("/") != 0, PathMissingError, "unable to chdir()");
|
||||
|
||||
TEST_RESULT_STR(strPtr(walPath(strNew("relative/path"))), "/relative/path", "relative path");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
|
Loading…
x
Reference in New Issue
Block a user