From a5b2630d7c089b229f48e2f9cbd1e9b390fcf496 Mon Sep 17 00:00:00 2001 From: Cynthia Shang Date: Mon, 27 Apr 2020 10:49:05 -0400 Subject: [PATCH] Throw user-friendly error if expire is not run on repository host. Running the expire command on a non-repository host threw an assertion because the command is not yet configured for remote execution. --- doc/xml/release.xml | 10 ++++++++++ src/command/expire/expire.c | 7 ++++--- test/src/module/command/expireTest.c | 14 +++++++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index e34083ed2..d4e036a49 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -23,6 +23,16 @@

Add backup/expire running status to the info command.

+ + + + + + + +

Throw user-friendly error if expire is not run on repository host.

+
+
diff --git a/src/command/expire/expire.c b/src/command/expire/expire.c index 7936ba0d3..870152b92 100644 --- a/src/command/expire/expire.c +++ b/src/command/expire/expire.c @@ -12,6 +12,7 @@ Expire Command #include "info/infoArchive.h" #include "info/infoBackup.h" #include "info/manifest.h" +#include "protocol/helper.h" #include "storage/helper.h" #include @@ -640,11 +641,11 @@ cmdExpire(void) { FUNCTION_LOG_VOID(logLevelDebug); + // Verify the repo is local + repoIsLocalVerify(); + MEM_CONTEXT_TEMP_BEGIN() { - // Get the repo storage in case it is remote and encryption settings need to be pulled down - storageRepo(); - // Load the backup.info InfoBackup *infoBackup = infoBackupLoadFileReconstruct( storageRepo(), INFO_BACKUP_PATH_FILE_STR, cipherType(cfgOptionStr(cfgOptRepoCipherType)), diff --git a/test/src/module/command/expireTest.c b/test/src/module/command/expireTest.c index cc674b5c0..05ba8072c 100644 --- a/test/src/module/command/expireTest.c +++ b/test/src/module/command/expireTest.c @@ -477,11 +477,23 @@ testRun(void) // ***************************************************************************************************************************** if (testBegin("removeExpiredArchive() & cmdExpire()")) { + TEST_TITLE("check repo local"); + + // Load Parameters + StringList *argList = strLstNew(); + strLstAddZ(argList, "--stanza=db"); + strLstAddZ(argList, "--repo1-retention-full=1"); // avoid warning + strLstAddZ(argList, "--repo1-host=/repo/not/local"); + harnessCfgLoad(cfgCmdExpire, argList); + + TEST_ERROR_FMT( + cmdExpire(), HostInvalidError, "expire command must be run on the repository host"); + //-------------------------------------------------------------------------------------------------------------------------- TEST_TITLE("retention-archive not set"); // Load Parameters - StringList *argList = strLstDup(argListBase); + argList = strLstDup(argListBase); harnessCfgLoad(cfgCmdExpire, argList); // Create backup.info without current backups