@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.cjs CHANGED
@@ -1227,7 +1227,7 @@ var ThreadbaseProvider = class {
1227
1227
 
1228
1228
  // src/scanner.ts
1229
1229
  var import_events = require("events");
1230
- var import_fs10 = require("fs");
1230
+ var import_fs11 = require("fs");
1231
1231
  var import_os2 = require("os");
1232
1232
  var import_path9 = require("path");
1233
1233
 
@@ -1524,6 +1524,9 @@ function classify(filePath, existing) {
1524
1524
  return { change: "reindex", stat: stat4 };
1525
1525
  }
1526
1526
 
1527
+ // src/persistent/index-engine.ts
1528
+ var import_fs10 = require("fs");
1529
+
1527
1530
  // src/providers/parse.ts
1528
1531
  var import_fs8 = require("fs");
1529
1532
  var import_readline3 = require("readline");
@@ -2583,7 +2586,13 @@ var PersistentEngine = class {
2583
2586
  await this.ensureCheckpoints(filePath, total);
2584
2587
  const beforeIndex = options.beforeIndex ?? total;
2585
2588
  const fromIndex = Math.max(0, beforeIndex - options.limit);
2586
- const floor = this.checkpoints.floor(filePath, fromIndex);
2589
+ let floor = this.checkpoints.floor(filePath, fromIndex);
2590
+ if (floor) {
2591
+ try {
2592
+ if (floor.byteOffset > (0, import_fs10.statSync)(filePath).size) floor = null;
2593
+ } catch {
2594
+ }
2595
+ }
2587
2596
  return readPage(filePath, total, options, floor);
2588
2597
  }
2589
2598
  // Build or extend the checkpoint chain so it covers `total` messages. Cold
@@ -2880,7 +2889,7 @@ var ConversationScanner = class {
2880
2889
  const cached = statCache.get(filePath);
2881
2890
  if (cached) {
2882
2891
  try {
2883
- const s = (0, import_fs10.statSync)(filePath);
2892
+ const s = (0, import_fs11.statSync)(filePath);
2884
2893
  if (s.mtimeMs === cached.stat.mtimeMs && s.size === cached.stat.size) {
2885
2894
  return cached.meta;
2886
2895
  }
@@ -3378,13 +3387,13 @@ var ConversationScanner = class {
3378
3387
  if (previous?.provider) return void 0;
3379
3388
  let sample = "";
3380
3389
  try {
3381
- const fd = (0, import_fs10.openSync)(filePath, "r");
3390
+ const fd = (0, import_fs11.openSync)(filePath, "r");
3382
3391
  try {
3383
3392
  const buf = Buffer.alloc(8192);
3384
- const n = (0, import_fs10.readSync)(fd, buf, 0, buf.length, 0);
3393
+ const n = (0, import_fs11.readSync)(fd, buf, 0, buf.length, 0);
3385
3394
  sample = buf.subarray(0, n).toString("utf8");
3386
3395
  } finally {
3387
- (0, import_fs10.closeSync)(fd);
3396
+ (0, import_fs11.closeSync)(fd);
3388
3397
  }
3389
3398
  } catch {
3390
3399
  return void 0;