feat: delete remote images from Lsky when record/attachment is deleted (keys stored at upload, legacy URLs resolved via pathname)

This commit is contained in:
root
2026-10-17 10:10:19 +08:00
parent fdf383a832
commit c39a4c80d5
3 changed files with 79 additions and 9 deletions
+3 -3
View File
@@ -125,7 +125,7 @@ function preMigrateColumns(d) {
}
};
for (const t of SYNC_TABLES) addCols(t, SYNC_COLS);
addCols('attachment', [['sha256', 'TEXT'], ['thumb_rel_path', 'TEXT'], ['remote_url', 'TEXT'], ['remote_thumb', 'TEXT']]);
addCols('attachment', [['sha256', 'TEXT'], ['thumb_rel_path', 'TEXT'], ['remote_url', 'TEXT'], ['remote_thumb', 'TEXT'], ['remote_key', 'TEXT'], ['remote_thumb_key', 'TEXT']]);
}
export function migrateSync(d) {
@@ -1084,8 +1084,8 @@ function listFootprints(d, query) {
if (!row) throw new Error('附件不存在');
withTx(d, () => {
const h = hlcNext(d);
d.prepare('UPDATE attachment SET remote_url=COALESCE(?, remote_url), remote_thumb=COALESCE(?, remote_thumb), hlc=? WHERE id=?')
.run(payload.remote_url ?? null, payload.remote_thumb ?? null, h, row.id);
d.prepare('UPDATE attachment SET remote_url=COALESCE(?, remote_url), remote_thumb=COALESCE(?, remote_thumb), remote_key=COALESCE(?, remote_key), remote_thumb_key=COALESCE(?, remote_thumb_key), hlc=? WHERE id=?')
.run(payload.remote_url ?? null, payload.remote_thumb ?? null, payload.remote_key ?? null, payload.remote_thumb_key ?? null, h, row.id);
touchOplog(d, 'attachment', row.uuid, 'upsert', h);
});
return { ok: true };