]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix org#2376 Update numvols after deleting a volume
authorEric Bollengier <eric@baculasystems.com>
Mon, 2 Feb 2026 07:32:57 +0000 (08:32 +0100)
committerEric Bollengier <eric@baculasystems.com>
Mon, 2 Feb 2026 07:39:01 +0000 (08:39 +0100)
bacula/src/dird/ua_cmds.c

index 1f3a3e988bb297a0a70da25861d29aced6e87a94..16cfbd3c7b42c2bb79682870f79947092dd34952 100644 (file)
@@ -2327,7 +2327,20 @@ static int delete_a_volume(UAContext *ua, MEDIA_DBR *mr)
    /* Keep track of this important event */
    ua->send_events("DC0010", EVENTS_TYPE_COMMAND, "delete volume=%s", mr->VolumeName);
 
+   POOL_DBR pr;
+   pr.PoolId = mr->PoolId;
+
+   db_lock(ua->db);
    db_delete_media_record(ua->jcr, ua->db, mr);
+   /* Don't compute NumVols here */
+   if (db_get_pool_record(ua->jcr, ua->db, &pr)) {
+      /* NumVols is updated here */
+      db_update_pool_record(ua->jcr, ua->db, &pr);
+      /* If we cannot update the pool record, it will be done the next time, or
+       * it's not a problem
+       */
+   }
+   db_unlock(ua->db);
    return 1;
 }