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