Skip to content

Commit fa55117

Browse files
committed
- add new command to purge the cache items
1 parent 033c959 commit fa55117

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

aura/cache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def iter_items(cls, tags=None) -> Generator[CacheItem, None, None]:
5252
else:
5353
yield obj
5454

55-
5655
@property
5756
def mtime(self) -> int:
5857
return self.item_stat.st_mtime

aura/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ def check_requirement():
255255
commands.check_requirement(payload)
256256

257257

258+
@cli.command()
259+
@click.option("--tag", "-t", multiple=True)
260+
def cleanup(tag=None):
261+
commands.cleanup(cache_tags=tag)
262+
263+
258264
def main():
259265
if "AURA_USER" in os.environ:
260266
username = os.environ["AURA_USER"]

aura/commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from . import utils
2222
from . import mirror
2323
from . import typos
24+
from . import cache
2425
from .analyzers.detections import Detection
2526
from .output.base import ScanOutputBase, DiffOutputBase, InfoOutputBase, TyposquattingOutputBase
2627

@@ -228,3 +229,8 @@ def generate_typosquatting(distance=2, limit=None, pkgs=None, format_uri="text",
228229
formatter = TyposquattingOutputBase.from_uri(format_uri)
229230
formatter.output_typosquatting(islice(typos.enumerator(combinations, f, extended=extended), 0, limit))
230231

232+
233+
def cleanup(cache_tags):
234+
cache_items = tuple(cache.CacheItem.iter_items(tags=cache_tags))
235+
click.confirm(f"You are about to delete {len(cache_items)} cache items. Proceed?", abort=True)
236+
cache.CacheItem.cleanup(items=cache_items)

0 commit comments

Comments
 (0)