From: Roland Häder Date: Tue, 15 Aug 2023 19:05:10 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f3cbe19f5b022493e1ad8ba0379b881691960564;p=fba.git Continued: - don't invoke federation.fetch_instances() when last_instance_fetch is recently being updated (means recently being fetch already) - column for instances.is_recent() needs to now only start with "last_" - don't determine unknown software if instances was recently fetched --- diff --git a/fba/http/federation.py b/fba/http/federation.py index 75f006b..53dff1e 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -59,7 +59,7 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: raise ValueError("Parameter 'command' is empty") elif command in ["fetch_blocks", "fetch_cs", "fetch_bkali", "fetch_relays", "fetch_fedipact", "fetch_joinmobilizon", "fetch_joinmisskey", "fetch_joinfediverse"] and origin is None: raise ValueError(f"Parameter command='{command}' but origin is None, please fix invoking this function.") - elif software is None: + elif software is None and not instances.is_recent(domain, "last_nodeinfo"): try: logger.debug("Software for domain='%s' is not set, determining ...", domain) software = determine_software(domain, path) @@ -72,6 +72,8 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'") elif not isinstance(path, str) and path is not None: raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'") + elif instances.is_recent(domain, "last_instance_fetch"): + raise ValueError(f"domain='{domain}' has recently been fetched but function was invoked") logger.debug("Checking if domain='%s' is registered ...", domain) if not instances.is_registered(domain): diff --git a/fba/models/instances.py b/fba/models/instances.py index 18cd7b6..1bd2884 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -301,7 +301,7 @@ def is_recent(domain: str, column: str = "last_instance_fetch") -> bool: if not isinstance(column, str): raise ValueError(f"Parameter column[]='{type(column)}' is not of type 'str'") - elif column not in ["last_instance_fetch", "last_blocked", "last_nodeinfo"]: + elif not column.startswith("last_"): raise ValueError(f"Parameter column='{column}' is not expected") elif not is_registered(domain): logger.debug("domain='%s' is not registered, returning False - EXIT!", domain)