mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Cleanup cache on platform update
This commit is contained in:
@ -243,6 +243,11 @@ class ContentCache(object):
|
||||
util.rmtree_(self.cache_dir)
|
||||
|
||||
|
||||
def clean_cache():
|
||||
with ContentCache() as cc:
|
||||
cc.clean()
|
||||
|
||||
|
||||
def sanitize_setting(name, value):
|
||||
if name not in DEFAULT_SETTINGS:
|
||||
raise InvalidSettingName(name)
|
||||
|
@ -16,7 +16,7 @@ import json
|
||||
|
||||
import click
|
||||
|
||||
from platformio import exception, util
|
||||
from platformio import app, exception, util
|
||||
from platformio.managers.platform import PlatformFactory, PlatformManager
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ def _print_platforms(platforms):
|
||||
@click.option("--json-output", is_flag=True)
|
||||
def platform_search(query, json_output):
|
||||
platforms = []
|
||||
for platform in util.get_api_result("/platforms", cache_valid="365d"):
|
||||
for platform in util.get_api_result("/platforms", cache_valid="30d"):
|
||||
if query == "all":
|
||||
query = ""
|
||||
|
||||
@ -116,6 +116,9 @@ def platform_uninstall(platforms):
|
||||
help="Do not update, only check for new version")
|
||||
@click.option("--json-output", is_flag=True)
|
||||
def platform_update(platforms, only_packages, only_check, json_output):
|
||||
# cleanup cached board and platform lists
|
||||
app.clean_cache()
|
||||
|
||||
pm = PlatformManager()
|
||||
if not platforms:
|
||||
platforms = []
|
||||
|
@ -42,11 +42,6 @@ def in_silence(ctx=None):
|
||||
(ctx.args[0] == "upgrade" or "--json-output" in ctx_args))
|
||||
|
||||
|
||||
def clean_cache():
|
||||
with app.ContentCache() as cc:
|
||||
cc.clean()
|
||||
|
||||
|
||||
def on_platformio_start(ctx, force, caller):
|
||||
if not caller:
|
||||
if getenv("PLATFORMIO_CALLER"):
|
||||
@ -65,7 +60,7 @@ def on_platformio_start(ctx, force, caller):
|
||||
telemetry.on_command()
|
||||
|
||||
if ctx.args and ctx.args[0] == "upgrade":
|
||||
clean_cache()
|
||||
app.clean_cache()
|
||||
if not in_silence(ctx):
|
||||
after_upgrade(ctx)
|
||||
|
||||
@ -160,7 +155,7 @@ def after_upgrade(ctx):
|
||||
app.set_state_item("last_version", __version__)
|
||||
else:
|
||||
click.secho("Please wait while upgrading PlatformIO ...", fg="yellow")
|
||||
clean_cache()
|
||||
app.clean_cache()
|
||||
u = Upgrader(last_version, __version__)
|
||||
if u.run(ctx):
|
||||
app.set_state_item("last_version", __version__)
|
||||
|
@ -149,7 +149,7 @@ class PlatformManager(BasePkgManager):
|
||||
@staticmethod
|
||||
@util.memoized
|
||||
def get_registered_boards():
|
||||
return util.get_api_result("/boards", cache_valid="365d")
|
||||
return util.get_api_result("/boards", cache_valid="30d")
|
||||
|
||||
def board_config(self, id_):
|
||||
for manifest in self.get_installed_boards():
|
||||
|
Reference in New Issue
Block a user