sliftutils 1.4.75 → 1.4.77

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/index.d.ts CHANGED
@@ -1547,7 +1547,7 @@ declare module "sliftutils/storage/BulkDatabase2/mergeMarkers" {
1547
1547
  }): Promise<void>;
1548
1548
  export declare function readDeleteMarkers(storage: FileStorage, allNames: string[]): Promise<DeleteMarker[]>;
1549
1549
  export declare function markerExclusions(markers: DeleteMarker[]): Set<string>;
1550
- export declare function processDeleteMarkers(storage: FileStorage, markers: DeleteMarker[], allNames: string[]): Promise<void>;
1550
+ export declare function processDeleteMarkers(name: string, storage: FileStorage, markers: DeleteMarker[], allNames: string[]): Promise<void>;
1551
1551
 
1552
1552
  }
1553
1553
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "1.4.75",
3
+ "version": "1.4.77",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -573,7 +573,7 @@ export class BulkDatabaseBase<T extends { key: string }> {
573
573
  const storage = await this.storage();
574
574
  const names = await storage.getKeys();
575
575
  const markers = await readDeleteMarkers(storage, names);
576
- if (markers.length) await processDeleteMarkers(storage, markers, names);
576
+ if (markers.length) await processDeleteMarkers(this.name, storage, markers, names);
577
577
  });
578
578
 
579
579
  private async writeBulkFile(rows: Record<string, unknown>[]): Promise<void> {
@@ -112,6 +112,9 @@ export async function runPlannedMerge(config: {
112
112
  } catch (e) {
113
113
  sourceOk[si] = false;
114
114
  log(`${magenta("skipped")} ${config.sourceNames[si]}: ${(e as Error).message}`);
115
+ // Stack goes straight to console (not the buffered step log) so the merge summary stays
116
+ // readable but we can still trace where the failure came from.
117
+ console.log(`${config.collectionName} skipped ${config.sourceNames[si]}:`, (e as Error).stack || e);
115
118
  }
116
119
  return map;
117
120
  }));
@@ -12,4 +12,4 @@ export declare function writeDeleteMarker(storage: FileStorage, config: {
12
12
  }): Promise<void>;
13
13
  export declare function readDeleteMarkers(storage: FileStorage, allNames: string[]): Promise<DeleteMarker[]>;
14
14
  export declare function markerExclusions(markers: DeleteMarker[]): Set<string>;
15
- export declare function processDeleteMarkers(storage: FileStorage, markers: DeleteMarker[], allNames: string[]): Promise<void>;
15
+ export declare function processDeleteMarkers(name: string, storage: FileStorage, markers: DeleteMarker[], allNames: string[]): Promise<void>;
@@ -15,6 +15,7 @@
15
15
  // the marker itself (kept around briefly so a concurrent reader still excludes the files consistently).
16
16
 
17
17
  import type { FileStorage } from "../FileFolderAPI";
18
+ import { blue, magenta } from "socket-function/src/formatting/logColors";
18
19
 
19
20
  const MARKER_PREFIX = ".delete-marker_";
20
21
  const MARKER_GRACE_MS = 5 * 60 * 1000;
@@ -67,7 +68,7 @@ export function markerExclusions(markers: DeleteMarker[]): Set<string> {
67
68
 
68
69
  // Act on each marker (see file header). Idempotent and best-effort: every removal is guarded, so two
69
70
  // processes (or two reads) running this at once just race to the same already-correct end state.
70
- export async function processDeleteMarkers(storage: FileStorage, markers: DeleteMarker[], allNames: string[]): Promise<void> {
71
+ export async function processDeleteMarkers(name: string, storage: FileStorage, markers: DeleteMarker[], allNames: string[]): Promise<void> {
71
72
  const present = new Set(allNames);
72
73
  const now = Date.now();
73
74
  for (const marker of markers) {
@@ -81,9 +82,12 @@ export async function processDeleteMarkers(storage: FileStorage, markers: Delete
81
82
  }
82
83
  const replacedExists = marker.replacedBy.length > 0 && marker.replacedBy.every(n => present.has(n));
83
84
  if (replacedExists || now - marker.time > MARKER_GRACE_MS) {
85
+ const reason = replacedExists ? `replacements landed` : `marker aged ${Math.round((now - marker.time) / 1000)}s`;
86
+ let deleted = 0;
84
87
  for (const n of stillPresent) {
85
- try { await storage.remove(n); } catch { /* already gone */ }
88
+ try { await storage.remove(n); deleted++; } catch { /* already gone */ }
86
89
  }
90
+ if (deleted) console.log(`${blue(name)} ${magenta("retire")}: deleted ${deleted} merged-away input file(s) (${reason})`);
87
91
  }
88
92
  }
89
93
  }