@threadbase-sh/scanner 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1161,7 +1161,7 @@ var ThreadbaseProvider = class {
1161
1161
 
1162
1162
  // src/scanner.ts
1163
1163
  import { EventEmitter } from "events";
1164
- import { closeSync as closeSync2, openSync as openSync2, readSync as readSync2, statSync as statSync2 } from "fs";
1164
+ import { closeSync as closeSync2, openSync as openSync2, readSync as readSync2, statSync as statSync3 } from "fs";
1165
1165
  import { homedir as homedir2 } from "os";
1166
1166
  import { join as join4 } from "path";
1167
1167
 
@@ -1458,6 +1458,9 @@ function classify(filePath, existing) {
1458
1458
  return { change: "reindex", stat: stat4 };
1459
1459
  }
1460
1460
 
1461
+ // src/persistent/index-engine.ts
1462
+ import { statSync as statSync2 } from "fs";
1463
+
1461
1464
  // src/providers/parse.ts
1462
1465
  import { createReadStream as createReadStream5 } from "fs";
1463
1466
  import { createInterface as createInterface3 } from "readline";
@@ -2517,7 +2520,13 @@ var PersistentEngine = class {
2517
2520
  await this.ensureCheckpoints(filePath, total);
2518
2521
  const beforeIndex = options.beforeIndex ?? total;
2519
2522
  const fromIndex = Math.max(0, beforeIndex - options.limit);
2520
- const floor = this.checkpoints.floor(filePath, fromIndex);
2523
+ let floor = this.checkpoints.floor(filePath, fromIndex);
2524
+ if (floor) {
2525
+ try {
2526
+ if (floor.byteOffset > statSync2(filePath).size) floor = null;
2527
+ } catch {
2528
+ }
2529
+ }
2521
2530
  return readPage(filePath, total, options, floor);
2522
2531
  }
2523
2532
  // Build or extend the checkpoint chain so it covers `total` messages. Cold
@@ -2814,7 +2823,7 @@ var ConversationScanner = class {
2814
2823
  const cached = statCache.get(filePath);
2815
2824
  if (cached) {
2816
2825
  try {
2817
- const s = statSync2(filePath);
2826
+ const s = statSync3(filePath);
2818
2827
  if (s.mtimeMs === cached.stat.mtimeMs && s.size === cached.stat.size) {
2819
2828
  return cached.meta;
2820
2829
  }