Publish cache-safe Russian text on site photographs, agent=codex

This commit is contained in:
german
2026-09-28 17:53:26 +03:00
parent c9ed6ec8e3
commit 97292166f3
39 changed files with 1699 additions and 27 deletions
+57 -1
View File
@@ -252,6 +252,61 @@ def update_motion():
sftp.close(); ssh.close()
def update_localized_photos():
"""Publish four Russian-lettered photos under new cache-safe asset names."""
previous = ROOT.parent / 'site-servaki-online-git' / 'public'
if not previous.is_dir():
raise RuntimeError('Previous Gitea release is required for the baseline check')
old = {p.relative_to(previous).as_posix(): digest(p.read_bytes())
for p in previous.rglob('*') if p.is_file()}
new = manifest()
slugs = ('video-surveillance', 'horeca', 'agriculture', 'construction')
pages = {'services/video-surveillance/index.html',
*(f'industries/{slug}/index.html' for slug in slugs if slug != 'video-surveillance')}
assets = {f'assets/editorial/photo-{slug}-ru-{width}.webp'
for slug in slugs for width in (480, 960, 1536)}
changed = {rel for rel in new if new[rel] != old.get(rel)}
if set(old) - set(new) or changed != pages | assets:
raise RuntimeError('Unexpected Russian-photo release scope: ' + repr(sorted(changed ^ (pages | assets))))
local_backup = ROOT / 'release-backups' / '2026-09-28-before-russian-photos'
remote_backup = SITE + '/backup-2026-09-28-before-russian-photos'
ssh, sftp = connect()
try:
for rel, expected in old.items():
target = WEBROOT + '/' + rel
if not exists(sftp, target) or digest(remote_bytes(sftp, target)) != expected:
raise RuntimeError('Published baseline changed; stopped before writing: ' + rel)
for rel in assets:
if exists(sftp, WEBROOT + '/' + rel):
raise RuntimeError('New localized asset already exists: ' + rel)
mkdirs(sftp, remote_backup)
for rel in sorted(pages):
data = remote_bytes(sftp, WEBROOT + '/' + rel)
destination = local_backup / rel
destination.parent.mkdir(parents=True, exist_ok=True)
if destination.exists() and destination.read_bytes() != data:
raise RuntimeError('Local backup conflict: ' + rel)
destination.write_bytes(data)
remote_copy = remote_backup + '/' + rel
if exists(sftp, remote_copy):
if digest(remote_bytes(sftp, remote_copy)) != old[rel]:
raise RuntimeError('Remote backup conflict: ' + rel)
else:
put_atomic(sftp, destination, remote_copy)
for rel in sorted(assets):
put_atomic(sftp, ROOT / 'public' / rel, WEBROOT + '/' + rel)
for rel in sorted(pages):
put_atomic(sftp, ROOT / 'public' / rel, WEBROOT + '/' + rel,
replace=True, backup_dir=remote_backup)
for rel in changed:
if digest(remote_bytes(sftp, WEBROOT + '/' + rel)) != new[rel]:
raise RuntimeError('Published localized photo failed checksum: ' + rel)
print('Published Russian-lettered photos; changed files:', len(changed),
'verified previous files:', len(old), 'backup:', remote_backup)
finally:
sftp.close(); ssh.close()
def reprice():
"""Replace only the published homepage after verifying the six price tokens."""
before = json.loads((BACKUP / 'deployed.json').read_text(encoding='utf-8'))
@@ -304,4 +359,5 @@ def reprice():
if __name__ == '__main__':
{'audit': audit, 'deploy': deploy, 'verify': verify,
'reprice': reprice, 'update-motion': update_motion}[sys.argv[1]]()
'reprice': reprice, 'update-motion': update_motion,
'update-localized-photos': update_localized_photos}[sys.argv[1]]()