]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix bug #4379 certain fields of Media record not reset after Truncate command
authorKern Sibbald <kern@sibbald.com>
Tue, 20 Nov 2018 14:37:58 +0000 (15:37 +0100)
committerKern Sibbald <kern@sibbald.com>
Tue, 20 Nov 2018 14:37:58 +0000 (15:37 +0100)
bacula/src/cats/sql_update.c
bacula/src/dird/ua_purge.c

index ee85bd7e8dc6f14c7deb449c911f83c14b0a08ab..7a8bb4ee090111b06b6ca8a14dc94ec8827665c2 100644 (file)
@@ -375,7 +375,7 @@ int BDB::bdb_update_media_record(JCR *jcr, MEDIA_DBR *mr)
         "LabelType=%d,StorageId=%s,PoolId=%s,VolRetention=%s,VolUseDuration=%s,"
         "MaxVolJobs=%d,MaxVolFiles=%d,Enabled=%d,LocationId=%s,"
         "ScratchPoolId=%s,RecyclePoolId=%s,RecycleCount=%d,Recycle=%d,"
-        "ActionOnPurge=%d,CacheRetention=%s"
+        "ActionOnPurge=%d,CacheRetention=%s,EndBlock=%d"
         " WHERE VolumeName='%s'",
         mr->VolJobs, mr->VolFiles, mr->VolBlocks,
         edit_uint64(mr->VolBytes, ed1),
@@ -402,6 +402,7 @@ int BDB::bdb_update_media_record(JCR *jcr, MEDIA_DBR *mr)
         edit_uint64(mr->RecyclePoolId, ed15),
         mr->RecycleCount,mr->Recycle, mr->ActionOnPurge,
         edit_uint64(mr->CacheRetention, ed16),
+        mr->EndBlock,
         esc_name);
 
    Dmsg1(dbglevel1, "%s\n", cmd);
index d63fbf7c7abb8dff1f5ee504cff9aafcf3fc8159..1ea739e28ff382ef816867df9f905039f816a776 100644 (file)
@@ -626,6 +626,7 @@ static void truncate_volume(UAContext *ua, MEDIA_DBR *mr,
                  &VolBytes, &VolABytes, &VolType) == 3) {
 
          ok = true;
+         /* Clean up a few things in the media record */
          mr->VolBytes = VolBytes;
          mr->VolABytes = VolABytes;
          mr->VolType = VolType;
@@ -633,6 +634,11 @@ static void truncate_volume(UAContext *ua, MEDIA_DBR *mr,
          mr->VolParts = 1;
          mr->VolCloudParts = 0;
          mr->LastPartBytes = VolBytes;
+         mr->VolJobs = 0;
+         mr->VolBlocks = 1;
+         mr->VolHoleBytes = 0;
+         mr->VolHoles = 0;
+         mr->EndBlock = 1;
 
          set_storageid_in_mr(NULL, mr);
          if (!db_update_media_record(ua->jcr, ua->db, mr)) {