Skip to content

Commit d3a723f

Browse files
committed
Fix clean_download_cache, add deleting of separate packages
1 parent 94afb59 commit d3a723f

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

pythonforandroid/toolchain.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ def add_parser(subparsers, *args, **kwargs):
364364
parents=[generic_parser])
365365
parser_clean_recipe_build.add_argument('recipe', help='The recipe name')
366366

367-
parser_clear_download_cache= add_parser(subparsers,
368-
'clear_download_cache', aliases=['clear-download-cache'],
367+
parser_clean_download_cache= add_parser(subparsers,
368+
'clean_download_cache', aliases=['clean-download-cache'],
369369
help='Delete any cached recipe downloads',
370370
parents=[generic_parser])
371371

@@ -578,13 +578,30 @@ def clean_recipe_build(self, args):
578578

579579
def clean_download_cache(self, args):
580580
'''
581-
Deletes any downloaded recipe packages.
581+
Deletes a download cache for recipes stated as arguments. If no
582+
argument is passed, it'll delete *all* downloaded cache. ::
583+
584+
p4a clean_download_cache kivy,pyjnius
582585
583586
This does *not* delete the build caches or final distributions.
584587
'''
585588
ctx = self.ctx
586-
if exists(ctx.packages_path):
587-
shutil.rmtree(ctx.packages_path)
589+
msg = "Download cache removed!"
590+
591+
if args.unknown_args:
592+
for package in args.unknown_args[0].split(','):
593+
remove_path = join(ctx.packages_path, package)
594+
if exists(remove_path):
595+
shutil.rmtree(remove_path)
596+
print(msg[:-1] + ' for: "{}"!'.format(package))
597+
else:
598+
print('No download cache for "{}" found!'.format(package))
599+
else:
600+
if exists(ctx.packages_path):
601+
shutil.rmtree(ctx.packages_path)
602+
print(msg)
603+
else:
604+
print('Nothing found at "{}"'.format(ctx.packages_path))
588605

589606
@require_prebuilt_dist
590607
def export_dist(self, args):

0 commit comments

Comments
 (0)