(cls, items: Optional[Iterable[CacheItem]]=None)
| 88 | |
| 89 | @classmethod |
| 90 | def cleanup(cls, items: Optional[Iterable[CacheItem]]=None): |
| 91 | cache_loc = Cache.get_location() |
| 92 | if cache_loc is None: |
| 93 | return |
| 94 | |
| 95 | total, used, free = shutil.disk_usage(cache_loc) |
| 96 | remaining = used |
| 97 | threshold = get_cache_threshold() |
| 98 | |
| 99 | if items is None: |
| 100 | items = cls.analyze() |
| 101 | |
| 102 | for x in items: # type: CacheItem |
| 103 | if x.is_expired: |
| 104 | pass |
| 105 | elif remaining < threshold: |
| 106 | continue |
| 107 | |
| 108 | remaining -= x.size |
| 109 | x.delete() |
| 110 | |
| 111 | |
| 112 | class Cache(ABC): |