Fix #135979: Extensions refresh does nothing for local repositories

Support refreshing the active repository for "local" repositories.

Co-authored-by: Nika Kutsniashvili <nickberckley@gmail.com>
This commit is contained in:
Campbell Barton
2025-04-10 15:33:58 +10:00
parent 39db404ba4
commit ab5875b2d5
2 changed files with 22 additions and 2 deletions

View File

@@ -1729,6 +1729,11 @@ class EXTENSIONS_OT_repo_refresh_all(Operator):
bl_idname = "extensions.repo_refresh_all"
bl_label = "Refresh Local"
use_active_only: BoolProperty(
name="Active Only",
description="Only refresh the active repository",
)
def _exceptions_as_report(self, repo_name, ex):
self.report({'WARNING'}, "{:s}: {:s}".format(repo_name, str(ex)))
@@ -1736,9 +1741,17 @@ class EXTENSIONS_OT_repo_refresh_all(Operator):
import importlib
import addon_utils
repos_all = extension_repos_read()
use_active_only = self.use_active_only
repos_all = extension_repos_read(use_active_only=use_active_only)
repo_cache_store = repo_cache_store_ensure()
if not repos_all:
if use_active_only:
self.report({'INFO'}, "The active repository has invalid settings")
else:
assert False, "unreachable" # Poll prevents this.
return {'CANCELLED'}
for repo_item in repos_all:
# Re-generate JSON meta-data from TOML files (needed for offline repository).
repo_cache_store.refresh_remote_from_directory(

View File

@@ -2119,7 +2119,14 @@ def extensions_repo_active_draw(self, _context):
if (repo := repo_active_or_none()) is not None:
layout.context_pointer_set("extension_repo", repo)
layout.operator("extensions.repo_sync_all", text="", icon='FILE_REFRESH').use_active_only = True
if repo is not None and repo.use_remote_url:
layout.operator("extensions.repo_sync_all", text="", icon='FILE_REFRESH').use_active_only = True
else:
# NOTE: this could be exposed for remote repositories, as it's possible users manipulate
# extensions on the file-system, then want to see the result of those changes locally.
# At the moment this can only be done by refreshing all local repositories from the top-level menu.
# Since it's a fairly obscure use case, leave this as-is.
layout.operator("extensions.repo_refresh_all", text="", icon='FILE_REFRESH').use_active_only = True
layout.separator()