Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor(usage): keep receipt durability within the accounting writer
[._.]/ Adam Eivy3a5b49080cd5
diff --git a/server/lib/fileCore.js b/server/lib/fileCore.jsindex f040eee879..1138f62b57 100644--- a/server/lib/fileCore.js+++ b/server/lib/fileCore.js@@ -56,7 +56,7 @@ const unsyncableDirs = new Set();* guarantee with one warning rather than failing a write that succeeded.* Windows cannot open a directory for fsync, so it is skipped there.*/-export async function syncDirectory(dir) {+async function syncDirectory(dir) {if (isWindows()) return;try {const handle = await open(dir, 'r');diff --git a/server/services/imageRenderUsage.js b/server/services/imageRenderUsage.jsindex 7b152ac182..7edc888424 100644--- a/server/services/imageRenderUsage.js+++ b/server/services/imageRenderUsage.js@@ -1,7 +1,7 @@import { createHash, randomUUID } from 'node:crypto';-import { link, readFile, readdir } from 'node:fs/promises';+import { link, open, readFile, readdir } from 'node:fs/promises';import { dirname, join } from 'node:path';-import { atomicWrite, ensureDir, unlinkGuarded, syncDirectory } from '../lib/fileCore.js';+import { atomicWrite, ensureDir, unlinkGuarded } from '../lib/fileCore.js';import { PATHS } from '../lib/paths.js';const ledgerDir = () => join(PATHS.data, 'image-render-usage');@@ -59,7 +59,12 @@ export async function publishAccountingFile(path, value) {await atomicWrite(staging, value);try {await link(staging, path);- await syncDirectory(dirname(path));+ // The file bytes were flushed by atomicWrite. Flush the new directory+ // entry too; Windows does not support opening directories for fsync.+ if (process.platform !== 'win32') {+ const directory = await open(dirname(path), 'r');+ try { await directory.sync(); } finally { await directory.close(); }+ }return true;} catch (err) {if (err.code !== 'EEXIST') throw err;