Key a finished picture by the credit it draws
A finished picture's key named its route, its options and its layers' keys, but not the credit
it draws from a pick. A pick whose author or licence changed while its file stayed the same kept
its photo layer's key, so the stored picture was served again with the old credit drawn on it,
while X-Credits already said the new one (seen locally for 1967, whose author lost Commons'
"upload by" appendix).
finished_key now also takes every text the picture draws from a pick: the credit of each layer
made from a pick's photo (Layer.from_pick, season and layout picks alike). A map's credit follows
its source, which its layer key already names. A picture drawn from no pick adds nothing to the
digest, so its key is the one it had: no kept race, session or pick-less season picture is drawn
again. Seen locally with the old store in place: the race poster, the session thumbnail and the
season poster with bg=none came from the store under their old keys; the 1967 and 1989 season
posters were drawn once under new keys. No release of master ever held a photo pick (neither
seasons/photos.json nor circuits/photos.json), so the running service keeps no picture whose key
changes.
The keys test: the same photo with another credit makes another key (on the old code finished_key
takes no credit; with the credit ignored the keys are equal), and a picture drawn from no pick
keeps the digest of render version, route, options and layer keys it had.
Builds: docs/posters.md at f6b9f937d0 (Finished images: the key names the credit of each layer drawn from a pick; Principles, 2: a changed input makes a new key)
Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
This commit is contained in:
+7
-3
@@ -187,10 +187,14 @@ def outline_layer_key(trace: str, frame: str, zoom: int) -> str:
|
||||
return f"outline/{trace}-{frame}-z{zoom}"
|
||||
|
||||
|
||||
def finished_key(route: str, options: Options, layer_keys: Iterable[str]) -> str:
|
||||
"""A finished picture's name in the store: its route, its options and the keys of the layers it was made from."""
|
||||
def finished_key(route: str, options: Options, layer_keys: Iterable[str], picked: Iterable[str] = ()) -> str:
|
||||
"""A finished picture's name in the store: its route, its options, the keys of the layers it was made from, and
|
||||
every text it draws from a pick (a photo's credit), so a changed credit makes a new key (docs/posters.md,
|
||||
principle 2). A picture drawn from no pick keeps the key it had before: nothing is added for it."""
|
||||
made_of = "|".join(sorted(layer_keys))
|
||||
digest = hashlib.sha256(f"{RENDER_VERSION}\n{route}\n{options.canonical()}\n{made_of}".encode()).hexdigest()
|
||||
texts = "\n".join(text for text in picked if text)
|
||||
drawn = f"\n{texts}" if texts else ""
|
||||
digest = hashlib.sha256(f"{RENDER_VERSION}\n{route}\n{options.canonical()}\n{made_of}{drawn}".encode()).hexdigest()
|
||||
return f"{digest[:40]}.{options.format}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user