*/
/*
- Copyright (C) 2002-2004 Kern Sibbald and John Walker
+ Copyright (C) 2002-20054 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
int recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
{
struct s_oldest_ctx oldest;
+ char ed1[50];
POOLMEM *query = get_pool_memory(PM_EMSG);
const char *select =
- "SELECT MediaId,LastWritten FROM Media "
- "WHERE PoolId=%u AND Recycle=1 AND VolStatus='Purged' "
- "AND MediaType='%s' %s"
- "ORDER BY LastWritten ASC,MediaId LIMIT 1";
+ "SELECT MediaId,LastWritten FROM Media "
+ "WHERE PoolId=%s AND Recycle=1 AND VolStatus='Purged' "
+ "AND MediaType='%s' %s"
+ "ORDER BY LastWritten ASC,MediaId LIMIT 1";
Dmsg0(100, "Enter recycle_oldest_purged_volume\n");
oldest.MediaId = 0;
if (InChanger) {
- Mmsg(query, select, mr->PoolId, mr->MediaType, "AND InChanger=1 ");
+ Mmsg(query, select, edit_int64(mr->PoolId, ed1), mr->MediaType,
+ "AND InChanger=1 ");
} else {
- Mmsg(query, select, mr->PoolId, mr->MediaType, "");
+ Mmsg(query, select, edit_int64(mr->PoolId, ed1), mr->MediaType, "");
}
if (!db_sql_query(jcr->db, query, oldest_handler, (void *)&oldest)) {
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);
- Dmsg1(100, "return 1 recycle_oldest_purged_volume Vol=%s\n", mr->VolumeName);
+ 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;
}
}
mr->VolJobs = mr->VolFiles = mr->VolBlocks = mr->VolErrors = 0;
mr->VolBytes = 1;
mr->FirstWritten = mr->LastWritten = 0;
+ mr->set_first_written = true;
return db_update_media_record(jcr, jcr->db, mr);
}