Validate that the file has not expired based on the I{duration}. @param fn: The file name. @type fn: str
(self, fn)
| 241 | pass |
| 242 | |
| 243 | def validate(self, fn): |
| 244 | """ |
| 245 | Validate that the file has not expired based on the I{duration}. |
| 246 | @param fn: The file name. |
| 247 | @type fn: str |
| 248 | """ |
| 249 | if self.duration[1] < 1: |
| 250 | return |
| 251 | created = dt.fromtimestamp(os.path.getctime(fn)) |
| 252 | d = {self.duration[0]: self.duration[1]} |
| 253 | expired = created+timedelta(**d) |
| 254 | if expired < dt.now(): |
| 255 | log.debug('%s expired, deleted', fn) |
| 256 | os.remove(fn) |
| 257 | |
| 258 | def clear(self): |
| 259 | for fn in os.listdir(self.location): |