From: Kern Sibbald Date: Sat, 22 Mar 2008 09:34:45 +0000 (+0000) Subject: Fix bug pointed out by Peter Much that causes the StorageId to X-Git-Tag: Release-7.0.0~4797 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e9c4f50627f57fa2b2e21d72f4ca84a1ef8d656c;p=bacula%2Fbacula Fix bug pointed out by Peter Much that causes the StorageId to be updated when reading a tape (during migration, it could have been incorrectly set to the write StorageId). git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6664 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 8fb433ab43..ee1d059c06 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -267,8 +267,10 @@ void catalog_request(JCR *jcr, BSOCK *bs) } } Dmsg2(400, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs); - /* Check if the volume has been written by the job, - * and update the LastWritten field if needed */ + /* + * Check if the volume has been written by the job, + * and update the LastWritten field if needed. + */ if (mr.VolBlocks != sdmr.VolBlocks && VolLastWritten != 0) { mr.LastWritten = VolLastWritten; } @@ -286,7 +288,12 @@ void catalog_request(JCR *jcr, BSOCK *bs) mr.VolWriteTime = sdmr.VolWriteTime; mr.VolParts = sdmr.VolParts; bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus)); - if (jcr->wstore && jcr->wstore->StorageId) { + /* + * Update to point to the last device used to write the Volume. + * However, do so only if we are writing the tape, i.e. + * the number of VolBlocks has increased. + */ + if (jcr->wstore && jcr->wstore->StorageId && mr.VolBlocks != sdmr.VolBlocks) { mr.StorageId = jcr->wstore->StorageId; }