/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2008 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
}
}
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 */
+ if (mr.VolBlocks != sdmr.VolBlocks) {
+ mr.LastWritten = sdmr.LastWritten;
+ }
/* Copy updated values to original media record */
mr.VolJobs = sdmr.VolJobs;
mr.VolFiles = sdmr.VolFiles;
mr.VolMounts = sdmr.VolMounts;
mr.VolErrors = sdmr.VolErrors;
mr.VolWrites = sdmr.VolWrites;
- mr.LastWritten = sdmr.LastWritten;
mr.Slot = sdmr.Slot;
mr.InChanger = sdmr.InChanger;
mr.VolReadTime = sdmr.VolReadTime;
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;
}
if (!db_create_jobmedia_record(jcr, jcr->db, &jm)) {
Jmsg(jcr, M_FATAL, 0, _("Catalog error creating JobMedia record. %s"),
db_strerror(jcr->db));
- bs->fsend(_("1991 Update JobMedia error\n"));
+ bs->fsend(_("1992 Create JobMedia error\n"));
} else {
Dmsg0(400, "JobMedia record created\n");
bs->fsend(OK_create);
if (!jcr->db) {
omsg = get_memory(bs->msglen+1);
pm_strcpy(omsg, bs->msg);
- bs->fsend(_("1991 Invalid Catalog Update: %s"), omsg);
+ bs->fsend(_("1994 Invalid Catalog Update: %s"), omsg);
Jmsg1(jcr, M_FATAL, 0, _("Invalid Catalog Update; DB not open: %s"), omsg);
free_memory(omsg);
goto bail_out;