- 文件道任务 scrapeMedia:NFO 原子写入、图片经图片缓存下载(并发 4,失败不阻塞 NFO)、只补缺失 / 全部覆盖
- 设置 organize.scrapeAfterImport / scrapeMode / scrapeImages / scrapeEpisodeThumbs
- POST /library/{id}/scrape、详情 scrape 状态;files/scrape writeNfo 与 scrape-batch write 走同一任务
- 迁移 0057_media_scrape、原因码、审计 organize.scrape
- 与 MP 输出的 NFO 差分测试(apps/server/test/scrape)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
39 lines
1.8 KiB
TypeScript
39 lines
1.8 KiB
TypeScript
import type { Kysely } from "kysely";
|
|
import { execDdl } from "../src/migration-helpers.ts";
|
|
|
|
// SCR-1 刮削:每部作品最近一次刮削(往媒体库目录写 NFO 与图片)的状态与逐文件结果。
|
|
// 一部作品一行,重新刮削覆盖;历史看审计(organize.scrape)与引擎运行记录。
|
|
|
|
// biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型
|
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
await execDdl(
|
|
db,
|
|
`create table if not exists media_scrape (
|
|
media_entity_id uuid primary key references media_entity (id) on delete cascade,
|
|
status text not null default 'queued' check (status in ('queued', 'running', 'succeeded', 'partial', 'failed')),
|
|
trigger text not null default 'manual' check (trigger in ('auto', 'manual')),
|
|
mode text not null default 'missing' check (mode in ('missing', 'overwrite')),
|
|
record_id uuid references organization_record (id) on delete set null,
|
|
engine_run_id text,
|
|
requested_at timestamptz not null default now(),
|
|
started_at timestamptz,
|
|
finished_at timestamptz,
|
|
written integer not null default 0,
|
|
skipped integer not null default 0,
|
|
failed integer not null default 0,
|
|
reason text,
|
|
files jsonb not null default '[]'::jsonb,
|
|
created_at timestamptz not null default now(),
|
|
updated_at timestamptz not null default now()
|
|
);
|
|
drop trigger if exists media_scrape_touch_updated_at on media_scrape;
|
|
create trigger media_scrape_touch_updated_at before update on media_scrape
|
|
for each row execute function umt_touch_updated_at();`,
|
|
);
|
|
}
|
|
|
|
// biome-ignore lint/suspicious/noExplicitAny: 同上
|
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
await execDdl(db, "drop table if exists media_scrape;");
|
|
}
|