Merge branch 'blender-v4.2-release'

This commit is contained in:
Campbell Barton 2024-07-02 17:06:40 +10:00
commit 9103f9682d
3 changed files with 40 additions and 6 deletions

@ -156,9 +156,7 @@ def repo_active_or_none():
return active_repo
def repo_stats_calc_outdated_for_repo_directory(repo_directory):
repo_cache_store = repo_cache_store_ensure()
def repo_stats_calc_outdated_for_repo_directory(repo_cache_store, repo_directory):
pkg_manifest_local = repo_cache_store.refresh_local_from_directory(
directory=repo_directory,
error_fn=print,
@ -194,6 +192,9 @@ def repo_stats_calc():
return
import os
repo_cache_store = repo_cache_store_ensure()
package_count = 0
for repo_item in bpy.context.preferences.extensions.repos:
@ -211,7 +212,7 @@ def repo_stats_calc():
if not os.path.isdir(repo_directory):
continue
package_count += repo_stats_calc_outdated_for_repo_directory(repo_directory)
package_count += repo_stats_calc_outdated_for_repo_directory(repo_cache_store, repo_directory)
bpy.context.window_manager.extensions_updates = package_count

@ -34,12 +34,42 @@ WM_EXTENSIONS_UPDATE_CHECKING = -1
# Internal Utilities
def sync_status_count_outdated_extensions(repos_notify):
from . import repo_stats_calc_outdated_for_repo_directory
from . import (
repo_cache_store_ensure,
repo_stats_calc_outdated_for_repo_directory,
)
from .bl_extension_ops import (
repo_cache_store_refresh_from_prefs,
)
repo_cache_store = repo_cache_store_ensure()
# NOTE: while this shouldn't happen frequently, preferences may have changed since the notification started.
# Some UI interactions can reliably cause this, for example - changing the URL which triggers a notification,
# then disabling immediately after for example. It can also happen when notifications are enabled on startup
# and the user disables a repository quickly after Blender opens.
# Whatever the cause, this should not raise an unhandled exception so check
# directories are still valid before calculating their outdated packages.
#
# This could be handled a few different ways, ignore the outcome entirely or calculate what's left.
# Opt for calculating what we can since ignoring the results entirely might mean updated aren't displayed
# in the status bar when they should be, accepting that a new notification might need to be calculated
# again for a correct result (repositories may have been enabled for example too).
repos = repo_cache_store_refresh_from_prefs(repo_cache_store)
repo_directories = {repo_directory for repo_directory, _repo_url in repos}
package_count = 0
for repo_item in repos_notify:
package_count += repo_stats_calc_outdated_for_repo_directory(repo_item.directory)
repo_directory = repo_item.directory
# Print as this is a corner case (if it happens often it's likely a bug).
if repo_directory not in repo_directories:
if bpy.app.debug:
print("Extension notify:", repo_directory, "no longer exists, skipping!")
continue
package_count += repo_stats_calc_outdated_for_repo_directory(repo_cache_store, repo_directory)
return package_count

@ -497,6 +497,9 @@ def repo_cache_store_refresh_from_prefs(repo_cache_store, include_disabled=False
repos.append((directory, remote_url))
repo_cache_store.refresh_from_repos(repos=repos)
# Return the repository directory & URL's as it can be useful to know which repositories are now available.
# NOTE: it might be better to return a list of `RepoItem`, for now it's not needed.
return repos
def _preferences_ensure_disabled(*, repo_item, pkg_id_sequence, default_set):