170 |
|
long age = System.currentTimeMillis() - lastModified; |
171 |
|
if(age > ((long) deleteOlderThan*1000)) { |
172 |
|
// it's also older than our age to delete older than |
173 |
< |
if(!alertFile.delete()) { |
173 |
> |
if(alertFile.delete()) { |
174 |
> |
// do a quick check to see if the directory is now empty |
175 |
> |
File[] newHostdirContents = hostdir.listFiles(); |
176 |
> |
if(newHostdirContents.length == 0) { |
177 |
> |
// it does seem to be, try and delete it |
178 |
> |
// this will fail anyway if files still remain |
179 |
> |
if(!hostdir.delete()) { |
180 |
> |
_logger.write(this.toString(), Logger.WARNING, "Failed to delete the following empty host directory: "+hostdir.getPath()); |
181 |
> |
} |
182 |
> |
} |
183 |
> |
} |
184 |
> |
else { |
185 |
|
_logger.write(this.toString(), Logger.WARNING, "Failed to delete the following 'old' alert file: "+alertFile.getPath()); |
186 |
|
} |
187 |
|
} |