613 |
613 |
# started more than two days ago, probably aborted job
|
614 |
614 |
job.remove_self()
|
615 |
615 |
|
616 |
|
def clean_tempfiles(self):
|
617 |
|
now = time.time()
|
618 |
|
one_month_ago = now - 30 * 86400
|
619 |
|
dirname = os.path.join(self.app_dir, 'tempfiles')
|
|
616 |
def _clean_files(self, limit, dirname):
|
620 |
617 |
if not os.path.exists(dirname):
|
621 |
618 |
return
|
622 |
619 |
for filename in os.listdir(dirname):
|
623 |
|
if os.stat(os.path.join(dirname, filename))[8] < one_month_ago:
|
|
620 |
if os.stat(os.path.join(dirname, filename))[8] < limit:
|
624 |
621 |
try:
|
625 |
622 |
os.unlink(os.path.join(dirname, filename))
|
626 |
623 |
except OSError:
|
627 |
624 |
pass
|
628 |
625 |
|
|
626 |
def clean_tempfiles(self):
|
|
627 |
now = time.time()
|
|
628 |
one_month_ago = now - 30 * 86400
|
|
629 |
self._clean_files(one_month_ago, os.path.join(self.app_dir, 'tempfiles'))
|
|
630 |
|
|
631 |
def clean_thumbnails(self):
|
|
632 |
now = time.time()
|
|
633 |
one_month_ago = now - 30 * 86400
|
|
634 |
self._clean_files(one_month_ago, os.path.join(self.app_dir, 'thumbs'))
|
|
635 |
|
629 |
636 |
@classmethod
|
630 |
637 |
def register_cronjobs(cls):
|
631 |
638 |
cls.register_cronjob(CronJob(cls.clean_sessions, minutes=range(0, 60, 5), name='clean_sessions'))
|
632 |
639 |
cls.register_cronjob(CronJob(cls.clean_nonces, minutes=range(0, 60, 5), name='clean_nonces'))
|
633 |
640 |
cls.register_cronjob(CronJob(cls.clean_afterjobs, minutes=[0], name='clean_afterjobs'))
|
634 |
641 |
cls.register_cronjob(CronJob(cls.clean_tempfiles, minutes=[0], name='clean_tempfiles'))
|
|
642 |
cls.register_cronjob(CronJob(cls.clean_thumbnails, minutes=[0], name='clean_thumbnails'))
|
635 |
643 |
|
636 |
644 |
_initialized = False
|
637 |
645 |
|
638 |
|
-
|