]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix bug #2343 where truncate of explicit Volume name truncates non-purged volumes
authorKern Sibbald <kern@sibbald.com>
Sun, 27 May 2018 09:38:39 +0000 (11:38 +0200)
committerKern Sibbald <kern@sibbald.com>
Sun, 27 May 2018 09:39:13 +0000 (11:39 +0200)
bacula/src/dird/ua_purge.c

index 5bffaeb6fadf9403cd3dd5a0ad5793f68c20142e..6d85b91950ef93510ddf0935bbd9c9ce00a45652 100644 (file)
@@ -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) {