fix(web,mobile): new replies show overwritten local images#23212
0 / 10 viewed10 files changedLine totals unavailable
scripts/fixtures/image-cache-proof.py · Earlier revision e76c4191 · right 44–45
Original diff
@@ -0,0 +1,72 @@
+#!/usr/bin/env python3
+"""Seed static image replies by cloning app-written V2 rows; stop the sandbox server first.
+
+Example: python3 scripts/fixtures/image-cache-proof.py --db .t3/userdata/statev2.sqlite
+--thread <app-created-thread-id> --workspace /tmp/issue-15676/workspace
+Requires Pillow for labelled PNG fixtures. This changes projections only, not event history.
+"""
+import argparse, json, pathlib, sqlite3
+from PIL import Image, ImageDraw, ImageFont
+
+p = argparse.ArgumentParser()
+p.add_argument('--db', type=pathlib.Path)
+p.add_argument('--thread')
+p.add_argument('--template-thread')
+p.add_argument('--workspace', type=pathlib.Path, required=True)
+p.add_argument('--color', choices=['blue', 'yellow'], default='blue')
+p.add_argument('--images-only', action='store_true')
+p.add_argument('--board', action='store_true')
+p.add_argument('--supplement', action='store_true')
+a = p.parse_args()
+f = json.loads(pathlib.Path(__file__).with_suffix('.json').read_text())
+font = ImageFont.truetype('/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf', 28)
+label, color, ink = ('BLUE v1', '#1261e8', 'white') if a.color == 'blue' else ('YELLOW v2', '#ffe100', 'black')
+def png(path, size):
+ image = Image.new('RGB', size, color)
+ ImageDraw.Draw(image).text((12, 24), label, font=font, fill=ink)
+ image.save(path)
+assets = a.workspace / 'fixtures'
+assets.mkdir(parents=True, exist_ok=True)
+png(f['imagePath'], (360, 100))
+png(assets / 'chart.png', (360, 100))
+png(assets / 'chart space.png', (360, 100))
+png(assets / 'tall.png', (180, 280))
+(assets / 'chart.svg').write_text('<svg xmlns="http://www.w3.org/2000/svg" width="360" height="100" viewBox="0 0 360 100"><rect width="360" height="100" fill="'+color+'"/><text x="12" y="55" font-size="28" fill="'+ink+'">'+label+' SVG</text></svg>')
+if a.images_only:
+ raise SystemExit()
+if not a.db or not a.thread:
+ p.error('--db and --thread are required for projection seeding')
+resolved = a.db.resolve()
+if '.t3' not in resolved.parts or resolved.is_relative_to(pathlib.Path.home() / '.t3'):
+ p.error('Only an isolated worktree .t3 database is supported')
+c = sqlite3.connect(resolved)
+c.row_factory = sqlite3.Row
+with sqlite3.connect(str(resolved)+'.image-proof-backup') as backup:
+ c.backup(backup)scripts/fixtures/image-cache-proof.py · right 44–45
scripts/fixtures/image-cache-proof.py · Earlier revision e76c4191 · right 22
Original diff
@@ -0,0 +1,72 @@
+#!/usr/bin/env python3
+"""Seed static image replies by cloning app-written V2 rows; stop the sandbox server first.
+
+Example: python3 scripts/fixtures/image-cache-proof.py --db .t3/userdata/statev2.sqlite
+--thread <app-created-thread-id> --workspace /tmp/issue-15676/workspace
+Requires Pillow for labelled PNG fixtures. This changes projections only, not event history.
+"""
+import argparse, json, pathlib, sqlite3
+from PIL import Image, ImageDraw, ImageFont
+
+p = argparse.ArgumentParser()
+p.add_argument('--db', type=pathlib.Path)
+p.add_argument('--thread')
+p.add_argument('--template-thread')
+p.add_argument('--workspace', type=pathlib.Path, required=True)
+p.add_argument('--color', choices=['blue', 'yellow'], default='blue')
+p.add_argument('--images-only', action='store_true')
+p.add_argument('--board', action='store_true')
+p.add_argument('--supplement', action='store_true')
+a = p.parse_args()
+f = json.loads(pathlib.Path(__file__).with_suffix('.json').read_text())
+font = ImageFont.truetype('/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf', 28)