} else {
ed2[0] = 0;
}
+ Dmsg1(050, "Scratch pool=%s\n", ed2);
/*
* ed2 ends up with scratch poolid and current poolid or
* just current poolid if there is no scratch pool
Mmsg(query, select, ed1, ed2, mr->MediaType, "");
}
+ Dmsg1(050, "query=%s\n", query.c_str());
if (!db_get_query_dbids(ua->jcr, ua->db, query, ids)) {
Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
goto bail_out;
}
+ Dmsg1(050, "num_ids=%d\n", ids.num_ids);
+
/* Visit each Volume and Prune it until we find one that is purged */
for (i=0; i<ids.num_ids; i++) {
MEDIA_DBR lmr;
memset(&lmr, 0, sizeof(lmr));
lmr.MediaId = ids.DBId[i];
- Dmsg1(150, "Get record MediaId=%d\n", (int)lmr.MediaId);
+ Dmsg1(050, "Get record MediaId=%d\n", (int)lmr.MediaId);
if (!db_get_media_record(jcr, jcr->db, &lmr)) {
Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
continue;
*/
if (ok && lmr.PoolId == mr->PoolId) {
Dmsg2(050, "Vol=%s MediaId=%d purged.\n", lmr.VolumeName, (int)lmr.MediaId);
- mr = &lmr; /* struct copy */
- break;
+ mr = &lmr; /* struct copy */
+ break; /* got a volume */
+ }
+ /*
+ * We purged something but did not get a volume in the current pool.
+ * It must be a scratch volume, so try to get it.
+ */
+ if (ok && get_scratch_volume(jcr, InChanger, mr)) {
+ break; /* got a volume */
}
+ ok = false; /* clear OK, in case we fall out */
+ } else {
+ Dmsg2(050, "Nothing pruned MediaId=%d Volume=%s\n", (int)lmr.MediaId, lmr.VolumeName);
}
}