1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-30 05:39:12 +02:00

Improve working directory error message.

Improve the wording of the error message and add a hint to make it clearer what is wrong and how the user can fix it.

Also change the assert to a regular error since this is not an internal error.
This commit is contained in:
David Steele 2020-09-11 10:10:25 -04:00 committed by GitHub
parent dac182c06e
commit fc77c51182
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 5 deletions

View File

@ -15,6 +15,15 @@
<release date="XXXX-XX-XX" version="2.30dev" title="UNDER DEVELOPMENT">
<release-core-list>
<release-improvement-list>
<release-item>
<release-item-contributor-list>
<release-item-contributor id="david.steele"/>
<release-item-reviewer id="stefan.fercot"/>
</release-item-contributor-list>
<p>Improve working directory error message.</p>
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-contributor id="david.christensen"/>

View File

@ -352,10 +352,16 @@ walPath(const String *walFile, const String *pgPath, const String *command)
char newWorkDir[4096];
THROW_ON_SYS_ERROR(getcwd(newWorkDir, sizeof(newWorkDir)) == NULL, FormatError, "unable to get cwd");
// Error if the new working directory is not equal to the original current working directory. This means that
// PostgreSQL and pgBackrest have a different idea about where the PostgreSQL data directory is located.
// Error if the new working directory is not equal to the original current working directory. This means that PostgreSQL
// and pgBackrest have a different idea about where the PostgreSQL data directory is located.
if (strcmp(currentWorkDir, newWorkDir) != 0)
THROW_FMT(AssertError, "working path '%s' is not the same path as '%s'", currentWorkDir, strZ(pgPath));
{
THROW_FMT(
OptionInvalidValueError,
PG_NAME " working directory '%s' is not the same as option " CFGOPT_PG1_PATH " '%s'\n"
"HINT: is the " PG_NAME " data_directory configured the same as the " CFGOPT_PG1_PATH " option?",
currentWorkDir, strZ(pgPath));
}
}
result = strNewFmt("%s/%s", strZ(pgPath), strZ(walFile));

View File

@ -208,8 +208,10 @@ testRun(void)
THROW_ON_SYS_ERROR(chdir("/") != 0, PathMissingError, "unable to chdir()");
TEST_ERROR(
walPath(strNew("relative/path"), pgPathLink, strNew("test")), AssertError,
hrnReplaceKey("working path '/' is not the same path as '{[path]}/pg-link'"));
walPath(strNew("relative/path"), pgPathLink, strNew("test")), OptionInvalidValueError,
hrnReplaceKey(
"PostgreSQL working directory '/' is not the same as option pg1-path '{[path]}/pg-link'\n"
"HINT: is the PostgreSQL data_directory configured the same as the pg1-path option?"));
TEST_ERROR(
walPath(strNew("relative/path"), NULL, strNew("test")), OptionRequiredError,