pgbackrest.git / summary / log / commit / refs
commit ce33913a80697e2d2873e4e8d8975eb09bbf6bd3
Author: David Steele <david@pgbackrest.org>
Date: Wed Jun 17 15:44:13 2026 +0000
Unify the file remove error message.
storageRemove() (Posix and SFTP) threw the ad-hoc "unable to remove '%s'" while path remove used STORAGE_ERROR_PATH_REMOVE_FILE "unable to remove file '%s'", so the same failure was reported two different ways depending on the entry point.
Replace STORAGE_ERROR_PATH_REMOVE_FILE with STORAGE_ERROR_FILE_REMOVE and use it for both single-file and recursive path removal, so every file removal failure now reads "unable to remove file '%s'". The SFTP path remove detail is also separated with a colon ("...': libssh sftp [...]") to match similar messages instead of a bare space.
src/storage/posix/storage.c | 4 ++--
src/storage/sftp/storage.c | 8 ++++----
src/storage/storage.intern.h | 3 ++-
test/src/module/storage/posixTest.c | 6 +++---
test/src/module/storage/remoteTest.c | 3 ++-
test/src/module/storage/sftpTest.c | 19 +++++++++++--------
6 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/src/storage/posix/storage.c b/src/storage/posix/storage.c
index 5eef9afea..69c455d3d 100644
--- a/src/storage/posix/storage.c
+++ b/src/storage/posix/storage.c
@@ -476,7 +476,7 @@ storagePosixPathRemove(THIS_VOID, const String *const path, const bool recurse,
}
// Else error
else
- THROW_SYS_ERROR_FMT(PathRemoveError, STORAGE_ERROR_PATH_REMOVE_FILE, strZ(file)); // {vm_covered}
+ THROW_SYS_ERROR_FMT(PathRemoveError, STORAGE_ERROR_FILE_REMOVE, strZ(file)); // {vm_covered}
}
// Reset the memory context occasionally so we don't use too much memory or slow down processing
@@ -566,7 +566,7 @@ storagePosixRemove(THIS_VOID, const String *const file, const StorageInterfaceRe
if (unlink(strZ(file)) == -1)
{
if (param.errorOnMissing || errno != ENOENT) // {vm_covered}
- THROW_SYS_ERROR_FMT(FileRemoveError, "unable to remove '%s'", strZ(file)); // {vm_covered}
+ THROW_SYS_ERROR_FMT(FileRemoveError, STORAGE_ERROR_FILE_REMOVE, strZ(file)); // {vm_covered}
}
FUNCTION_LOG_RETURN_VOID();
diff --git a/src/storage/sftp/storage.c b/src/storage/sftp/storage.c
index 5c3ab3721..76248a62a 100644
--- a/src/storage/sftp/storage.c
+++ b/src/storage/sftp/storage.c
@@ -895,7 +895,7 @@ storageSftpRemove(THIS_VOID, const String *const file, const StorageInterfaceRem
{
storageSftpEvalLibSsh2Error(
rc, libssh2_sftp_last_error(this->sftpSession), &FileRemoveError,
- strNewFmt("unable to remove '%s'", strZ(file)), NULL);
+ strNewFmt(STORAGE_ERROR_FILE_REMOVE, strZ(file)), NULL);
}
}
else
@@ -904,7 +904,7 @@ storageSftpRemove(THIS_VOID, const String *const file, const StorageInterfaceRem
{
storageSftpEvalLibSsh2Error(
rc, libssh2_sftp_last_error(this->sftpSession), &FileRemoveError,
- strNewFmt("unable to remove '%s'", strZ(file)), NULL);
+ strNewFmt(STORAGE_ERROR_FILE_REMOVE, strZ(file)), NULL);
}
}
}
@@ -1116,12 +1116,12 @@ storageSftpPathRemove(THIS_VOID, const String *const path, const bool recurse, c
else
{
THROW_FMT(
- PathRemoveError, STORAGE_ERROR_PATH_REMOVE_FILE " libssh sftp [%" PRIu64 "] %s", strZ(file),
+ PathRemoveError, STORAGE_ERROR_FILE_REMOVE ": libssh sftp [%" PRIu64 "] %s", strZ(file),
sftpErrno, libssh2SftpErrorMsg(sftpErrno));
}
}
else
- THROW_FMT(PathRemoveError, STORAGE_ERROR_PATH_REMOVE_FILE " libssh ssh [%d]", strZ(file), rc);
+ THROW_FMT(PathRemoveError, STORAGE_ERROR_FILE_REMOVE ": libssh ssh [%d]", strZ(file), rc);
}
// Reset the memory context occasionally so we don't use too much memory or slow down processing
diff --git a/src/storage/storage.intern.h b/src/storage/storage.intern.h
index 28b886076..dabb72a0c 100644
--- a/src/storage/storage.intern.h
+++ b/src/storage/storage.intern.h
@@ -39,8 +39,9 @@ Error messages
#define STORAGE_ERROR_LIST_INFO "unable to list file info for path '%s'"
#define STORAGE_ERROR_LIST_INFO_MISSING "unable to list file info for missing path '%s'"
+#define STORAGE_ERROR_FILE_REMOVE "unable to remove file '%s'"
+
#define STORAGE_ERROR_PATH_REMOVE "unable to remove path '%s'"
-#define STORAGE_ERROR_PATH_REMOVE_FILE "unable to remove file '%s'"
#define STORAGE_ERROR_PATH_REMOVE_MISSING "unable to remove missing path '%s'"
#define STORAGE_ERROR_PATH_SYNC "unable to sync path '%s'"
diff --git a/test/src/module/storage/posixTest.c b/test/src/module/storage/posixTest.c
index 4a65b7c7e..a4f184440 100644
--- a/test/src/module/storage/posixTest.c
+++ b/test/src/module/storage/posixTest.c
@@ -828,7 +828,7 @@ testRun(void)
TEST_ERROR_FMT(
storagePathRemoveP(storageTest, pathRemove1, .recurse = true), PathRemoveError,
- STORAGE_ERROR_PATH_REMOVE_FILE ": [13] Permission denied", strZ(fileRemove));
+ "unable to remove file '%s': [13] Permission denied", strZ(fileRemove));
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("path remove - path with subpath and file removed");
@@ -1178,7 +1178,7 @@ testRun(void)
TEST_RESULT_VOID(storageRemoveP(storageTest, STRDEF("missing")), "remove missing file");
TEST_ERROR(
storageRemoveP(storageTest, STRDEF("missing"), .errorOnMissing = true), FileRemoveError,
- "unable to remove '" TEST_PATH "/missing': [2] No such file or directory");
+ "unable to remove file '" TEST_PATH "/missing': [2] No such file or directory");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("remove - file exists");
@@ -1193,7 +1193,7 @@ testRun(void)
TEST_TITLE("remove - permission denied");
TEST_ERROR_FMT(
- storageRemoveP(storageTest, fileNoPerm), FileRemoveError, "unable to remove '%s': [13] Permission denied",
+ storageRemoveP(storageTest, fileNoPerm), FileRemoveError, "unable to remove file '%s': [13] Permission denied",
strZ(fileNoPerm));
#endif // TEST_CONTAINER_REQUIRED
}
diff --git a/test/src/module/storage/remoteTest.c b/test/src/module/storage/remoteTest.c
index 50a118488..abd2dbde3 100644
--- a/test/src/module/storage/remoteTest.c
+++ b/test/src/module/storage/remoteTest.c
@@ -604,7 +604,8 @@ testRun(void)
TEST_ERROR(
storageRemoveP(storageRepoWrite, file, .errorOnMissing = true), FileRemoveError,
- "raised from remote-0 shim protocol: unable to remove '" TEST_PATH "/repo128/file.txt': [2] No such file or directory");
+ "raised from remote-0 shim protocol: unable to remove file '" TEST_PATH "/repo128/file.txt':"
+ " [2] No such file or directory");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("ignore missing file");
diff --git a/test/src/module/storage/sftpTest.c b/test/src/module/storage/sftpTest.c
index 6c0c68080..24acc9ccc 100644
--- a/test/src/module/storage/sftpTest.c
+++ b/test/src/module/storage/sftpTest.c
@@ -2379,7 +2379,7 @@ testRun(void)
TEST_ERROR_FMT(
storagePathRemoveP(storageTest, pathRemove1, .recurse = true), PathRemoveError,
- STORAGE_ERROR_PATH_REMOVE_FILE " libssh ssh [-7]", strZ(pathRemove2));
+ "unable to remove file '%s': libssh ssh [-7]", strZ(pathRemove2));
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("path remove - other than LIBSSH2_FX_FAILURE/LIBSSH2_FX_PERMISSION_DENIED");
@@ -2394,7 +2394,7 @@ testRun(void)
TEST_ERROR_FMT(
storagePathRemoveP(storageTest, pathRemove1, .recurse = true), PathRemoveError,
- STORAGE_ERROR_PATH_REMOVE_FILE " libssh sftp [7] connection lost", strZ(pathRemove2));
+ "unable to remove file '%s': libssh sftp [7] connection lost", strZ(pathRemove2));
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("path remove - unlink LIBSSH2_ERROR_EAGAIN timeout");
@@ -3655,8 +3655,9 @@ testRun(void)
HRN_LIBSSH2_UNLINK("/missing", .resultInt = LIBSSH2_ERROR_SFTP_PROTOCOL),
HRN_LIBSSH2_SFTP_ERROR(LIBSSH2_FX_NO_SUCH_FILE));
- TEST_ERROR(storageRemoveP(storageTest, STRDEF("missing"), .errorOnMissing = true), FileRemoveError,
- "unable to remove '/missing': libssh2 error [-31]: sftp error [2] no such file");
+ TEST_ERROR(
+ storageRemoveP(storageTest, STRDEF("missing"), .errorOnMissing = true), FileRemoveError,
+ "unable to remove file '/missing': libssh2 error [-31]: sftp error [2] no such file");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("remove - file missing, sftp error other than LIBSSH2_FX_NO_SUCH_FILE");
@@ -3668,8 +3669,9 @@ testRun(void)
HRN_LIBSSH2_SFTP_ERROR(LIBSSH2_FX_CONNECTION_LOST),
HRN_LIBSSH2_SFTP_ERROR(LIBSSH2_FX_CONNECTION_LOST));
- TEST_ERROR(storageRemoveP(storageTest, STRDEF("missing")), FileRemoveError,
- "unable to remove '/missing': libssh2 error [-31]: sftp error [7] connection lost");
+ TEST_ERROR(
+ storageRemoveP(storageTest, STRDEF("missing")), FileRemoveError,
+ "unable to remove file '/missing': libssh2 error [-31]: sftp error [7] connection lost");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("remove - file missing, ssh error, .errorOnMissing = true");
@@ -3680,8 +3682,9 @@ testRun(void)
HRN_LIBSSH2_UNLINK("/missing", .resultInt = LIBSSH2_ERROR_BAD_SOCKET),
HRN_LIBSSH2_SFTP_ERROR(LIBSSH2_ERROR_NONE));
- TEST_ERROR(storageRemoveP(storageTest, STRDEF("missing"), .errorOnMissing = true), FileRemoveError,
- "unable to remove '/missing': libssh2 error [-45]");
+ TEST_ERROR(
+ storageRemoveP(storageTest, STRDEF("missing"), .errorOnMissing = true), FileRemoveError,
+ "unable to remove file '/missing': libssh2 error [-45]");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("remove - file missing, timeout EAGAIN, .errorOnMissing = true");
[parent: 7fd8bc89a15c]