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: an unreadable data root reports an unknown file count in the overview (#12994)

[._.]/ Adam Eivy58d2f60222f9
diff --git a/server/services/dataManager.js b/server/services/dataManager.js
index ece9e1090f..ff9e2297f9 100644
--- a/server/services/dataManager.js
+++ b/server/services/dataManager.js
@@ -370,8 +370,10 @@ function invalidateOverviewScan() {
}
async function scanDataTree(strict) {
+ let rootUnreadable = false;
const entries = await readdir(DATA_DIR, { withFileTypes: true }).catch((err) => {
if (strict) throw err;
+ rootUnreadable = true;
return [];
});
const dirs = entries.filter(e => e.isDirectory());
@@ -398,10 +400,10 @@ async function scanDataTree(strict) {
const fileSizes = values.slice(dirs.length);
let totalSize = fileSizes.reduce((sum, n) => sum + n, 0);
- let totalFileCount = topFiles.length;
+ let totalFileCount = rootUnreadable ? null : topFiles.length;
for (const r of dirResults) {
totalSize += r.size;
- // A failed non-strict walk reports a null count; keep the total unknown too.
+ // A failed non-strict walk or root listing reports a null count; keep the total unknown too.
totalFileCount = totalFileCount === null || r.fileCount === null ? null : totalFileCount + r.fileCount;
}
return { dirs, dirResults, totalSize, totalFileCount };
diff --git a/server/services/dataManager.strict.test.js b/server/services/dataManager.strict.test.js
index 2780604ed1..df43aa95f4 100644
--- a/server/services/dataManager.strict.test.js
+++ b/server/services/dataManager.strict.test.js
@@ -145,3 +145,10 @@ describe('dataManager overview scan sharing (#12994)', () => {
await expect(getDataOverview({ strict: true })).resolves.toMatchObject({ dataDir: 'data' });
});
});
+
+it('reports an unreadable data root as an unknown count rather than an empty tree', async () => {
+ rmSync(testDataRoot, { recursive: true, force: true });
+ const overview = await getDataOverview();
+ expect(overview.categories).toEqual([]);
+ expect(overview.totalFileCount).toBeNull();
+});