Skip to content

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

fix: fail closed when the media asset quota scan errors (#12492)

[._.]/ Adam Eivy9e94c73f8492
diff --git a/server/services/federatedMedia/assetStore.js b/server/services/federatedMedia/assetStore.js
index e4dc2daeb7..ff77f149cf 100644
--- a/server/services/federatedMedia/assetStore.js
+++ b/server/services/federatedMedia/assetStore.js
@@ -199,10 +199,16 @@ async function storeAsset({ callerId, mimeType, declaredSha256, body, jobs = []
async function enforceAssetQuota(callerId, incomingBytes) {
const ownerPrefix = `${federatedMediaAssetOwner(callerId)}-`;
- const entries = await readdir(PATHS.federatedMediaInbox).catch(() => []);
+ // Fail closed: only a missing directory/entry (not yet created, or swept
+ // mid-scan) is safe to treat as empty; any other error refuses the upload.
+ const ignoreMissing = (error) => {
+ if (error?.code === 'ENOENT') return null;
+ throw error;
+ };
+ const entries = (await readdir(PATHS.federatedMediaInbox).catch(ignoreMissing)) || [];
const infos = await Promise.all(entries.map(async (name) => ({
name,
- info: await lstat(join(PATHS.federatedMediaInbox, name)).catch(() => null),
+ info: await lstat(join(PATHS.federatedMediaInbox, name)).catch(ignoreMissing),
})));
let totalBytes = 0;
let callerCount = 0;