image.ts 715 字节
Newer Older
P
Peter Pan 已提交
1
import type {Data, Worker} from './types';
P
Peter Pan 已提交
2 3 4 5 6 7 8 9 10 11 12 13

interface Image {
    step: number;
    wallTime: number;
}

const worker: Worker = async io => {
    const components = await io.getData<string[]>('/components');
    if (!components.includes('image')) {
        return;
    }

P
Peter Pan 已提交
14 15 16 17 18
    const {runs, tags} = await io.save<Data>('/image/tags');
    for (const [index, run] of runs.entries()) {
        for (const tag of tags[index]) {
            const list = (await io.save<Image[]>('/image/list', {run, tag})) ?? [];
            for (const [index, image] of list.entries()) {
P
Peter Pan 已提交
19 20 21 22 23 24 25
                await io.saveBinary('/image/image', {run, tag, index, ts: image.wallTime});
            }
        }
    }
};

export default worker;