fix: the launch cleanup leaves the Site videos' files alone
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Publish images (push) Has been cancelled
Build and deploy / Secret scan and release gate (push) Has been cancelled
Build and deploy / Integration suite on a real stack (push) Has been cancelled

Marcus, 2026-11-16: the whole Site tab stays. The cleanup marked every
upload expired, the files behind the Site's videos and captions too; it
now skips the uploads site_videos points at, and counts only what it
removes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-16 16:53:21 -03:00
parent 5ca4872e79
commit 8cc35c100f
2 changed files with 24 additions and 5 deletions

View File

@@ -25,6 +25,16 @@ def run():
status,amount_cents,response) VALUES(%s,%s,'mercadopago',%s,'card','approved',1490,%s) RETURNING id''',
(uuid4(), quote, str(uuid4()), Jsonb({'live_mode': True}))).fetchone()['id']
# A Site video's file stays: the whole Site tab is kept (Marcus, 2026-11-16).
video_upload, video_id = uuid4(), None
with db.connect() as c:
taken = {row['id'] for row in c.execute('SELECT id FROM dtf_local.site_videos').fetchall()}
video_id = next(name for name in ('retirada', 'sala', 'nota', 'avulsas', 'subindo', 'png') if name not in taken)
c.execute('''INSERT INTO dtf_local.uploads(id,owner,name,size,object_key,multipart_id,complete,expires_at)
VALUES(%s,%s,'reset-video.mp4',1,%s,'',true,now()+interval '30 days')''',
(video_upload, owner, f'reset-test/{video_upload}.mp4'))
c.execute("INSERT INTO dtf_local.site_videos(id,upload_id) VALUES(%s,%s)", (video_id, video_upload))
lines = []
# Real money paid: nothing happens, even when confirmed.
assert launch_reset.main(['--confirmar', 'APAGAR'], out=lines.append) == 1
@@ -47,7 +57,11 @@ def run():
for table in ('orders', 'quotes', 'payment_intents', 'movements', 'outbox'):
assert c.execute(f'SELECT count(*) AS n FROM dtf_local.{table}').fetchone()['n'] == 0, table
assert not c.execute('''SELECT 1 FROM dtf_local.uploads WHERE purged_at IS NULL
AND expires_at>now()''').fetchone()
AND expires_at>now() AND id<>%s''', (video_upload,)).fetchone()
assert c.execute('SELECT expires_at>now() AS kept FROM dtf_local.uploads WHERE id=%s',
(video_upload,)).fetchone()['kept']
c.execute('DELETE FROM dtf_local.site_videos WHERE id=%s', (video_id,))
c.execute('DELETE FROM dtf_local.uploads WHERE id=%s', (video_upload,))
assert c.execute('SELECT count(*) AS n FROM dtf_local.operators').fetchone()['n'] >= 1
assert any('Apagado.' in line for line in lines) and 'continua de onde parou' in lines[-1], lines
# The numbering is not reset: DTF-1…DTF-15 already exist in Tiny.
@@ -77,7 +91,7 @@ def run():
'4. Revisão', '5. Finalizado', 'Recibos', 'Revisões'):
assert list((root / name).iterdir()) == [], name
assert (root / 'Estampas' / '1001.png').read_bytes() == b'art'
print('PASS: launch cleanup refuses real payments, counts first, then removes test orders and quotes, keeping the numbering and the art library')
print('PASS: launch cleanup refuses real payments, counts first, then removes test orders and quotes, keeping the numbering, the Site videos\' files and the art library')
if __name__ == '__main__':