return stat;
}
-void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
+void catalog_request(JCR *jcr, BSOCK *bs)
{
MEDIA_DBR mr, sdmr;
JOBMEDIA_DBR jm;
if (sscanf(bs->msg, Find_media, &Job, &index, &pool_name, &mr.MediaType) == 4) {
memset(&pr, 0, sizeof(pr));
bstrncpy(pr.Name, pool_name, sizeof(pr.Name));
+ unbash_spaces(pr.Name);
ok = db_get_pool_record(jcr, jcr->db, &pr);
if (ok) {
mr.PoolId = pr.PoolId;
- ok = find_next_volume_for_append(jcr, &mr, true /*permit create new vol*/);
+ mr.StorageId = jcr->store->StorageId;
+ ok = find_next_volume_for_append(jcr, &mr, index, true /*permit create new vol*/);
}
/*
* Send Find Media response to Storage daemon
} else if (strcmp(mr.MediaType, jcr->store->media_type) != 0) {
reason = _("not correct MediaType");
} else {
- /*
- * ****FIXME***
- * This test (accept_any_volume) is turned off
- * because it doesn't properly check if the volume
- * really is out of sequence!
- *
- * } else if (!jcr->pool->accept_any_volume) {
- * reason = "Volume not in sequence";
- */
-
/*
* Now try recycling if necessary
* reason set non-NULL if we cannot use it
Jmsg(jcr, M_FATAL, 0, _("Volume Files at %u being set to %u"
" for Volume \"%s\". This is incorrect.\n"),
mr.VolFiles, sdmr.VolFiles, mr.VolumeName);
- bnet_fsend(bs, _("1992 Update Media error\n"));
+ bnet_fsend(bs, _("1992 Update Media error. VolFiles=%u, CatFiles=%u\n"),
+ sdmr.VolFiles, mr.VolFiles);
db_unlock(jcr->db);
return;
}
mr.VolWriteTime = sdmr.VolWriteTime;
mr.VolParts = sdmr.VolParts;
bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus));
+ if (jcr->store->StorageId) {
+ mr.StorageId = jcr->store->StorageId;
+ }
Dmsg2(400, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName);
/*
- * Check if it has expired, and if not update the DB. Note, if
- * Volume has expired, has_volume_expired() will update the DB.
+ * Update the database, then before sending the response to the
+ * SD, check if the Volume has expired.
*/
- if (has_volume_expired(jcr, &mr) || db_update_media_record(jcr, jcr->db, &mr)) {
- send_volume_info_to_storage_daemon(jcr, bs, &mr);
- } else {
+ if (!db_update_media_record(jcr, jcr->db, &mr)) {
Jmsg(jcr, M_FATAL, 0, _("Catalog error updating Media record. %s"),
db_strerror(jcr->db));
- bnet_fsend(bs, _("1992 Update Media error\n"));
+ bnet_fsend(bs, _("1993 Update Media error\n"));
Dmsg0(400, "send error\n");
+ } else {
+ (void)has_volume_expired(jcr, &mr);
+ send_volume_info_to_storage_daemon(jcr, bs, &mr);
}
db_unlock(jcr->db);
* VolSessionId, VolSessionTime, FileIndex, and file name
* to store in the catalog.
*/
-void catalog_update(JCR *jcr, BSOCK *bs, char *msg)
+void catalog_update(JCR *jcr, BSOCK *bs)
{
unser_declare;
uint32_t VolSessionId, VolSessionTime;
int len;
char *fname, *attr;
ATTR_DBR *ar = NULL;
+ POOLMEM *omsg;
if (!jcr->pool->catalog_files) {
return; /* user disabled cataloging */
}
+ if (!jcr->db) {
+ omsg = get_memory(bs->msglen+1);
+ pm_strcpy(omsg, bs->msg);
+ bnet_fsend(bs, _("1991 Invalid Catalog Update: %s"), omsg);
+ Jmsg1(jcr, M_FATAL, 0, _("Invalid Catalog Update; DB not open: %s"), omsg);
+ free_memory(omsg);
+ return;
+ }
+
/* Start transaction allocates jcr->attr and jcr->ar if needed */
db_start_transaction(jcr, jcr->db); /* start transaction if not already open */
ar = jcr->ar;
Dmsg2(400, "dird<filed: stream=%d %s\n", Stream, fname);
Dmsg1(400, "dird<filed: attr=%s\n", attr);
-#ifdef xxx
+#ifdef xxx_old_code
if (!db_create_file_attributes_record(jcr, jcr->db, ar)) {
Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db));
}