mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2026-07-10 16:37:15 +08:00
fix(cnr): eliminate client clock fallback dependency on timestamp sync
This commit is contained in:
parent
ec2023a5a3
commit
9a827e409a
@ -2,8 +2,8 @@ import asyncio
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import time
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from datetime import datetime, timedelta
|
||||||
from typing import List
|
from typing import List
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
@ -125,11 +125,13 @@ async def _get_cnr_data(sync_mode=None, dont_wait=True, **kwargs):
|
|||||||
is_cache_loading = True
|
is_cache_loading = True
|
||||||
|
|
||||||
if dont_wait:
|
if dont_wait:
|
||||||
|
is_cache_loading = False
|
||||||
if cached_data is not None:
|
if cached_data is not None:
|
||||||
return cached_data.get('nodes', [])
|
return cached_data.get('nodes', [])
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if cached_data is not None and manager_util.get_cache_state(uri, expired_days=1) == 'cached':
|
if cached_data is not None and manager_util.get_cache_state(uri, expired_days=1) == 'cached':
|
||||||
|
is_cache_loading = False
|
||||||
return cached_data.get('nodes', [])
|
return cached_data.get('nodes', [])
|
||||||
|
|
||||||
async def fetch_all(timestamp_filter, existing_nodes):
|
async def fetch_all(timestamp_filter, existing_nodes):
|
||||||
@ -172,7 +174,6 @@ async def _get_cnr_data(sync_mode=None, dont_wait=True, **kwargs):
|
|||||||
return {'nodes': list(nodes_map.values())}
|
return {'nodes': list(nodes_map.values())}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from datetime import datetime, timezone, timedelta
|
|
||||||
json_obj = await fetch_all(last_updated, full_nodes)
|
json_obj = await fetch_all(last_updated, full_nodes)
|
||||||
|
|
||||||
# Set cache's timestamp as the maximum timestamp from fetched nodes.
|
# Set cache's timestamp as the maximum timestamp from fetched nodes.
|
||||||
@ -188,7 +189,7 @@ async def _get_cnr_data(sync_mode=None, dont_wait=True, **kwargs):
|
|||||||
except Exception:
|
except Exception:
|
||||||
new_timestamp = max_timestamp
|
new_timestamp = max_timestamp
|
||||||
else:
|
else:
|
||||||
new_timestamp = last_updated if last_updated else datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
new_timestamp = last_updated
|
||||||
|
|
||||||
cache_to_save = {
|
cache_to_save = {
|
||||||
'nodes': json_obj['nodes'],
|
'nodes': json_obj['nodes'],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user