]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/recycle.c
Ensure that StorageId is updated after write
[bacula/bacula] / bacula / src / dird / recycle.c
index 3e8e4944ce041bfbb313f36cb42ed144f8575d37..4ceaf0b4c66dba3528cc0cedfddf8861207de4f7 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2002-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2002-2012 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.
@@ -32,7 +32,6 @@
  *
  *     Kern Sibbald, May MMII
  *
- *   Version $Id$
  */
 
 
 
 /* Forward referenced functions */
 
-bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
+bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr,
+                          STORE *store)
 {
    bstrncpy(mr->VolStatus, "Recycle", sizeof(mr->VolStatus));
+   set_storageid_in_mr(store, mr);
    if (db_find_next_volume(jcr, jcr->db, 1, InChanger, mr)) {
       jcr->MediaId = mr->MediaId;
       Dmsg1(20, "Find_next_vol MediaId=%u\n", jcr->MediaId);
       pm_strcpy(jcr->VolumeName, mr->VolumeName);
+      set_storageid_in_mr(store, mr);
       return true;
    }
    return false;
@@ -57,10 +59,12 @@ bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
 /*
  *   Look for oldest Purged volume
  */
-bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
+bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger,
+        MEDIA_DBR *mr, STORE *store)
 {
    bstrncpy(mr->VolStatus, "Purged", sizeof(mr->VolStatus));
    if (db_find_next_volume(jcr, jcr->db, 1, InChanger, mr)) {
+      set_storageid_in_mr(store, mr);
       if (recycle_volume(jcr, mr)) {
          Jmsg(jcr, M_INFO, 0, _("Recycled volume \"%s\"\n"), mr->VolumeName);
          Dmsg1(100, "return 1  recycle_oldest_purged_volume Vol=%s\n", mr->VolumeName);
@@ -82,5 +86,6 @@ int recycle_volume(JCR *jcr, MEDIA_DBR *mr)
    mr->FirstWritten = mr->LastWritten = 0;
    mr->RecycleCount++;
    mr->set_first_written = true;
+   set_storageid_in_mr(NULL, mr);
    return db_update_media_record(jcr, jcr->db, mr);
 }