]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/scratch.patch
ebl add #define in readme
[bacula/bacula] / bacula / patches / testing / scratch.patch
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
4 @@ -313,6 +313,7 @@
5     MEDIA_DBR smr;
6     POOL_DBR spr, pr;
7     bool ok = false;
8 +   bool found = false;
9     char ed1[50], ed2[50];
10  
11     /* Only one thread at a time can pull from the scratch pool */
12 @@ -328,9 +329,20 @@
13        if (InChanger) {       
14           smr.StorageId = mr->StorageId;  /* want only Scratch Volumes in changer */
15        }
16 -      bstrncpy(smr.VolStatus, "Append", sizeof(smr.VolStatus));  /* want only appendable volumes */
17        bstrncpy(smr.MediaType, mr->MediaType, sizeof(smr.MediaType));
18 +      
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)) {
22 +          found = true;
23 +      /* next, we can try to find an Recycled volume */
24 +      } else if (find_recycled_volume(jcr, InChanger, &smr)) {
25 +          found = true;
26 +      /* finaly, we take a Purged volume */
27 +      } else if (recycle_oldest_purged_volume(jcr, InChanger, &smr)) {
28 +          found = true;
29 +      }
30 +      if (found) {
31           POOL_MEM query(PM_MESSAGE);
32  
33           /*   
34 @@ -369,6 +381,9 @@
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
47 @@ -178,6 +178,9 @@
48  int get_num_drives_from_SD(UAContext *ua);
49  void update_slots(UAContext *ua);
50  
51 +/* ua_update.c */
52 +void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *opr);
53 +
54  /* ua_output.c */
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
60 @@ -569,6 +569,18 @@
61        }
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);
72 +         } else {
73 +            bsendmsg(ua, "%s", db_strerror(ua->db));
74 +         }
75 +      }
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
82 @@ -276,7 +276,7 @@
83  }
84  
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)
88  {
89     POOL_DBR pr;
90     POOLMEM *query;