1 diff -Naur cvs/src/dird/next_vol.c my/src/dird/next_vol.c
2 --- cvs/src/dird/next_vol.c 2006-11-15 22:16:02.000000000 +0100
3 +++ my/src/dird/next_vol.c 2006-11-15 23:47:43.000000000 +0100
11 /* Only one thread at a time can pull from the scratch pool */
14 smr.StorageId = mr->StorageId; /* want only Scratch Volumes in changer */
16 - bstrncpy(smr.VolStatus, "Append", sizeof(smr.VolStatus)); /* want only appendable volumes */
17 bstrncpy(smr.MediaType, mr->MediaType, sizeof(smr.MediaType));
19 + /* first, try to get Append volume */
20 + bstrncpy(smr.VolStatus, "Append", sizeof(smr.VolStatus));
21 if (db_find_next_volume(jcr, jcr->db, 1, InChanger, &smr)) {
23 + /* next, we can try to find an Recycled volume */
24 + } else if (find_recycled_volume(jcr, InChanger, &smr)) {
26 + /* finaly, we take a Purged volume */
27 + } else if (recycle_oldest_purged_volume(jcr, InChanger, &smr)) {
31 POOL_MEM query(PM_MESSAGE);
35 memcpy(mr, &smr, sizeof(MEDIA_DBR));
36 /* Set default parameters from current pool */
37 set_pool_dbr_defaults_in_media_dbr(mr, &pr);
38 + /* set_pool_dbr_defaults_in_media_dbr set VolStatus to Append,
39 + * we could have Recycled media */
40 + bstrncpy(mr->VolStatus, smr.VolStatus, sizeof(smr.VolStatus));
41 if (!db_update_media_record(jcr, jcr->db, mr)) {
42 Jmsg(jcr, M_WARNING, 0, _("Unable to update Volume record: ERR=%s"),
43 db_strerror(jcr->db));
44 diff -Naur cvs/src/dird/protos.h my/src/dird/protos.h
45 --- cvs/src/dird/protos.h 2006-11-15 22:16:02.000000000 +0100
46 +++ my/src/dird/protos.h 2006-11-15 23:26:50.000000000 +0100
48 int get_num_drives_from_SD(UAContext *ua);
49 void update_slots(UAContext *ua);
52 +void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *opr);
55 void prtit(void *ctx, const char *msg);
56 int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool);
57 diff -Naur cvs/src/dird/ua_purge.c my/src/dird/ua_purge.c
58 --- cvs/src/dird/ua_purge.c 2006-11-15 22:16:03.000000000 +0100
59 +++ my/src/dird/ua_purge.c 2006-11-15 23:55:14.000000000 +0100
62 pm_strcpy(jcr->VolumeName, mr->VolumeName);
63 generate_job_event(jcr, "VolumePurged");
64 + if (mr->RecyclePoolId && mr->RecyclePoolId != mr->PoolId) {
65 + POOL_DBR oldpr, newpr;
66 + memset(&oldpr, 0, sizeof(POOL_DBR));
67 + memset(&newpr, 0, sizeof(POOL_DBR));
68 + newpr.PoolId = mr->RecyclePoolId;
69 + oldpr.PoolId = mr->PoolId;
70 + if (db_get_pool_record(jcr, ua->db, &oldpr) && db_get_pool_record(jcr, ua->db, &newpr)) {
71 + update_vol_pool(ua, newpr.Name, mr, &oldpr);
73 + bsendmsg(ua, "%s", db_strerror(ua->db));
76 /* Send message to Job report, if it is a *real* job */
77 if (jcr && jcr->JobId > 0) {
78 Jmsg1(jcr, M_INFO, 0, _("All records pruned from Volume \"%s\"; marking it \"Purged\"\n"),
79 diff -Naur cvs/src/dird/ua_update.c my/src/dird/ua_update.c
80 --- cvs/src/dird/ua_update.c 2006-11-15 23:30:10.000000000 +0100
81 +++ my/src/dird/ua_update.c 2006-11-15 23:56:30.000000000 +0100
85 /* Modify the Pool in which this Volume is located */
86 -static void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *opr)
87 +void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *opr)