From: Kern Sibbald Date: Sun, 27 May 2018 09:38:39 +0000 (+0200) Subject: Fix bug #2343 where truncate of explicit Volume name truncates non-purged volumes X-Git-Tag: Release-9.0.8~5 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c4bb3494172f98ed9384c15402486e37835809b3;p=bacula%2Fbacula Fix bug #2343 where truncate of explicit Volume name truncates non-purged volumes --- diff --git a/bacula/src/dird/ua_purge.c b/bacula/src/dird/ua_purge.c index 5bffaeb6fa..6d85b91950 100644 --- a/bacula/src/dird/ua_purge.c +++ b/bacula/src/dird/ua_purge.c @@ -705,6 +705,11 @@ int truncate_cmd(UAContext *ua, const char *cmd) mr.clear(); mr.MediaId = results[i]; if (db_get_media_record(ua->jcr, ua->db, &mr)) { + if (strcasecmp(mr.VolStatus, "Purged") != 0) { + ua->send_msg(_("Truncate Volume \"%s\" skipped. Status is \"%s\", but must be \"Purged\".\n"), + mr.VolumeName, mr.VolStatus); + continue; + } if (drive < 0) { STORE *store = (STORE*)GetResWithName(R_STORAGE, storage); drive = get_storage_drive(ua, store); @@ -714,7 +719,7 @@ int truncate_cmd(UAContext *ua, const char *cmd) if (pr.PoolId == 0) { pr.PoolId = mr.PoolId; if (!db_get_pool_record(ua->jcr, ua->db, &pr)) { - return 1; + goto bail_out; /* free allocated memory */ } } if (strcasecmp("truncate", action) == 0) {