Calendar now = Calendar.getInstance();
now.setTimeInMillis(timenow);
Calendar threshold = hg._scheduler.getTrimTime(now);
for(int i=0; i<toRemove.size(); i++)
{
SimpleFSDirectory dir = (SimpleFSDirectory) toRemove.get(i).directory();
String path = dir.getFile().getName();
Calendar archivetime = null;
try
{
archivetime = HourglassDirectoryManagerFactory.getCalendarTime(path);
} catch (ParseException e)
{
log.error("index directory name bad. potential corruption. Move on without trimming.", e);
toKeep.add(toRemove.get(i));
continue;
}
if (archivetime.before(threshold))
{
log.info("trimming: remove " + path);
log.info(dir.getFile() + " -before--" + (dir.getFile().exists()?" not deleted ":" deleted"));
FileUtil.rmDir(dir.getFile());
log.info(dir.getFile() + " -after--" + (dir.getFile().exists()?" not deleted ":" deleted"));
} else
{
toKeep.add(toRemove.get(i));
}
}