/*
*
* Bacula Director -- Automatic Recycling of Volumes
- * Recycles Volumes that have been purged
+ * Recycles Volumes that have been purged
*
* Kern Sibbald, May MMII
*
*/
/*
- Copyright (C) 2002-20054 Kern Sibbald
+ Copyright (C) 2002-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
/* Forward referenced functions */
-int find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
+bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
{
bstrncpy(mr->VolStatus, "Recycle", sizeof(mr->VolStatus));
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);
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/*
* Look for oldest Purged volume
*/
-int recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
+bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
{
struct s_oldest_ctx oldest;
char ed1[50];
Dmsg0(100, "Enter recycle_oldest_purged_volume\n");
oldest.MediaId = 0;
if (InChanger) {
- Mmsg(query, select, edit_int64(mr->PoolId, ed1), mr->MediaType,
- "AND InChanger=1 ");
+ char changer[100];
+ bsnprintf(changer, sizeof(changer), "AND InChanger=1 AND StorageId=%s ",
+ edit_int64(mr->StorageId, ed1));
+ Mmsg(query, select, edit_int64(mr->PoolId, ed1), mr->MediaType, changer);
} else {
Mmsg(query, select, edit_int64(mr->PoolId, ed1), mr->MediaType, "");
}
Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
Dmsg0(100, "return 0 recycle_oldest_purged_volume query\n");
free_pool_memory(query);
- return 0;
+ return false;
}
free_pool_memory(query);
Dmsg1(100, "Oldest mediaid=%d\n", oldest.MediaId);
if (oldest.MediaId != 0) {
mr->MediaId = oldest.MediaId;
if (db_get_media_record(jcr, jcr->db, mr)) {
- if (recycle_volume(jcr, mr)) {
- Jmsg(jcr, M_INFO, 0, "Recycled volume \"%s\"\n", mr->VolumeName);
+ 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);
- return 1;
- }
+ return true;
+ }
}
Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
}
Dmsg0(100, "return 0 recycle_oldest_purged_volume end\n");
- return 0;
+ return false;
}
/*