MCPcopy Index your code
hub / github.com/WebODM/WebODM / cleanup_cache_directory

Function cleanup_cache_directory

worker/tasks.py:99–115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97
98@app.task(ignore_result=True)
99def cleanup_cache_directory():
100 # Delete files and folder in the task_assets folder after 30 days
101 task_assets_cache = os.path.join(settings.MEDIA_CACHE, "task_assets")
102 time_limit = 60 * 60 * 24 * 30
103
104 if os.path.isdir(task_assets_cache):
105 for f in os.listdir(task_assets_cache):
106 now = time.time()
107 filepath = os.path.join(task_assets_cache, f)
108 modified = os.stat(filepath).st_mtime
109 if modified < now - time_limit:
110 if os.path.isfile(filepath):
111 os.remove(filepath)
112 else:
113 shutil.rmtree(filepath, ignore_errors=True)
114
115 logger.info('Cleaned up: %s (%s)' % (filepath, modified))
116
117# Based on https://stackoverflow.com/questions/22498038/improve-current-implementation-of-a-setinterval-python/22498708#22498708
118def setInterval(interval, func, *args):

Callers

nothing calls this directly

Calls 1

removeMethod · 0.45

Tested by

no test coverage detected