plc-replica/scan.ts

30 lines
857 B
TypeScript
Raw Normal View History

2024-11-27 16:30:50 +00:00
import { TextLineStream } from "jsr:@std/streams@1/text-line-stream";
import { ExportEntry } from "./directory-tailer.ts";
import { tailer } from "./main.ts";
export const fullScan = async () => {
using exports = await Deno.open("./data/exports.jsonl", { read: true });
2024-11-28 03:08:47 +00:00
// interrupted at 2024-11-12T21:33:47.118Z
// byte offset
await exports.seek(13526812085, Deno.SeekMode.Start);
2024-11-27 16:30:50 +00:00
const lineStream = exports.readable
.pipeThrough(new TextDecoderStream())
.pipeThrough(new TextLineStream());
2024-11-28 03:08:47 +00:00
{
const reader = lineStream.getReader();
const line = await reader.read();
console.log("dropping: " + line.value);
reader.releaseLock();
}
2024-11-27 16:30:50 +00:00
for await (const line of lineStream.values()) {
const entry = JSON.parse(line) as unknown as ExportEntry;
2024-11-28 03:08:47 +00:00
await tailer.processRecord(entry, line);
2024-11-27 16:30:50 +00:00
}
};
await fullScan();