diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 5509acc5ab..0619aaa5d1 100644 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -364,10 +364,12 @@ def add_parser(subparsers, *args, **kwargs): parents=[generic_parser]) parser_clean_recipe_build.add_argument('recipe', help='The recipe name') - parser_clear_download_cache= add_parser(subparsers, - 'clear_download_cache', aliases=['clear-download-cache'], + parser_clean_download_cache= add_parser(subparsers, + 'clean_download_cache', aliases=['clean-download-cache'], help='Delete any cached recipe downloads', parents=[generic_parser]) + parser_clean_download_cache.add_argument('recipe', + help='The recipe name') parser_export_dist = add_parser(subparsers, 'export_dist', aliases=['export-dist'], @@ -578,13 +580,29 @@ def clean_recipe_build(self, args): def clean_download_cache(self, args): ''' - Deletes any downloaded recipe packages. + Deletes a download cache for recipes stated as arguments. If no + argument is passed, it'll delete *all* downloaded cache. :: + + p4a clean_download_cache kivy,pyjnius This does *not* delete the build caches or final distributions. ''' ctx = self.ctx - if exists(ctx.packages_path): - shutil.rmtree(ctx.packages_path) + msg = "Download cache removed!" + if args.recipe: + for package in args.recipe.split(','): + remove_path = join(ctx.packages_path, package) + if exists(remove_path): + shutil.rmtree(remove_path) + print(msg[:-1] + ' for: "{}"!'.format(package)) + else: + print('No download cache for "{}" found!'.format(package)) + else: + if exists(ctx.packages_path): + shutil.rmtree(ctx.packages_path) + print(msg) + else: + print('Nothing found at "{}"'.format(ctx.packages_path)) @require_prebuilt_dist def export_dist(self, args):