From edce1072951cfcf9e5bc7fdfce4045750d254bde Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Wed, 9 Jan 2013 16:10:10 +0100 Subject: [PATCH] Fix bug #1975 new label ignored when first is duplicate. When labelling a new volume, if an existing volume name is entered, subsequent entries are ignored and the original one is attempted each time. After the first call to db_get_media_record the MediaId of the media record is set and as such it will keep searching on MediaId instead of using the new entered named. So clear the MediaId and set the VolumeName and the call db_get_media_record so it will actually search for the new name and not for the already existing mediaid of the duplicate name entered before. --- bacula/src/dird/ua_label.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index aa008f031d..93899cbd27 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -415,7 +415,10 @@ checkName: continue; } + /* Search by Media name so set VolumeName and clear MediaId. */ + mr.MediaId = 0; bstrncpy(mr.VolumeName, ua->cmd, sizeof(mr.VolumeName)); + /* If VolBytes are zero the Volume is not labeled */ if (db_get_media_record(ua->jcr, ua->db, &mr)) { if (mr.VolBytes != 0) { -- 2.39.5