*/
/*
- Copyright (C) 2002 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
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);
+ pm_strcpy(jcr->VolumeName, mr->VolumeName);
return 1;
}
return 0;
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);
- char *select =
+ const char *select =
"SELECT MediaId,LastWritten FROM Media "
- "WHERE PoolId=%u AND Recycle=1 AND VolStatus='Purged' "
+ "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)) {
Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
}
Dmsg0(100, "return 0 recycle_oldest_purged_volume end\n");
- return 0;
+ return 0;
}
/*
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);
}