fix bogus metadata for extra networks appearing out of cache

fix description editing for checkpoint not immediately appearing on cards
This commit is contained in:
AUTOMATIC1111 2023-07-16 09:49:22 +03:00
parent f71630edb3
commit ccd97886da
3 changed files with 8 additions and 8 deletions

View File

@ -80,18 +80,18 @@ def cached_data_for_file(subsection, title, filename, func):
entry = existing_cache.get(title) entry = existing_cache.get(title)
if entry: if entry:
cached_mtime = existing_cache[title].get("mtime", 0) cached_mtime = entry.get("mtime", 0)
if ondisk_mtime > cached_mtime: if ondisk_mtime > cached_mtime:
entry = None entry = None
if not entry: if not entry:
entry = func() value = func()
if entry is None: if value is None:
return None return None
entry['mtime'] = ondisk_mtime entry = {'mtime': ondisk_mtime, 'value': value}
existing_cache[title] = entry existing_cache[title] = entry
dump_cache() dump_cache()
return entry return entry['value']

View File

@ -52,7 +52,7 @@ def get_metadata(page: str = "", item: str = ""):
if metadata is None: if metadata is None:
return JSONResponse({}) return JSONResponse({})
return JSONResponse({"metadata": metadata}) return JSONResponse({"metadata": json.dumps(metadata, indent=4, ensure_ascii=False)})
def get_single_card(page: str = "", tabname: str = "", name: str = ""): def get_single_card(page: str = "", tabname: str = "", name: str = ""):
@ -66,6 +66,7 @@ def get_single_card(page: str = "", tabname: str = "", name: str = ""):
errors.display(e, "creating item for extra network") errors.display(e, "creating item for extra network")
item = page.items.get(name) item = page.items.get(name)
page.read_user_metadata(item)
item_html = page.create_html_for_item(item, tabname) item_html = page.create_html_for_item(item, tabname)
return JSONResponse({"html": item_html}) return JSONResponse({"html": item_html})

View File

@ -13,7 +13,7 @@ class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
shared.refresh_checkpoints() shared.refresh_checkpoints()
def create_item(self, name, index=None): def create_item(self, name, index=None):
checkpoint: sd_models.CheckpointInfo = sd_models.checkpoints_list.get(name) checkpoint: sd_models.CheckpointInfo = sd_models.checkpoint_aliases.get(name)
path, ext = os.path.splitext(checkpoint.filename) path, ext = os.path.splitext(checkpoint.filename)
return { return {
"name": checkpoint.name_for_extra, "name": checkpoint.name_for_extra,
@ -24,7 +24,6 @@ class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
"onclick": '"' + html.escape(f"""return selectCheckpoint({quote_js(name)})""") + '"', "onclick": '"' + html.escape(f"""return selectCheckpoint({quote_js(name)})""") + '"',
"local_preview": f"{path}.{shared.opts.samples_format}", "local_preview": f"{path}.{shared.opts.samples_format}",
"sort_keys": {'default': index, **self.get_sort_keys(checkpoint.filename)}, "sort_keys": {'default': index, **self.get_sort_keys(checkpoint.filename)},
} }
def list_items(self): def list_items(self):