rename scan.ts to scan-from-raw.ts and give it a simple cli for byteoffset
This commit is contained in:
parent
1e0ff83f8b
commit
e9af92c00f
1 changed files with 13 additions and 6 deletions
|
@ -2,18 +2,18 @@ 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 () => {
|
||||
export const fullScan = async (fromByteOffset?: number) => {
|
||||
using exports = await Deno.open("./data/exports.jsonl", { read: true });
|
||||
|
||||
// interrupted at 2024-11-12T21:33:47.118Z
|
||||
// byte offset
|
||||
await exports.seek(13526812085, Deno.SeekMode.Start);
|
||||
if (fromByteOffset) {
|
||||
await exports.seek(fromByteOffset, Deno.SeekMode.Start);
|
||||
}
|
||||
|
||||
const lineStream = exports.readable
|
||||
.pipeThrough(new TextDecoderStream())
|
||||
.pipeThrough(new TextLineStream());
|
||||
|
||||
{
|
||||
if (fromByteOffset) {
|
||||
const reader = lineStream.getReader();
|
||||
const line = await reader.read();
|
||||
console.log("dropping: " + line.value);
|
||||
|
@ -26,4 +26,11 @@ export const fullScan = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
await fullScan();
|
||||
if (import.meta.main) {
|
||||
const fromByteOffsetStr = Deno.args.at(0);
|
||||
const fromByteOffset = fromByteOffsetStr
|
||||
? parseInt(fromByteOffsetStr)
|
||||
: undefined;
|
||||
|
||||
await fullScan(fromByteOffset);
|
||||
}
|
Loading…
Reference in a new issue