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: resolve browser downloads on Windows (#8683)

[._.]/ Adam Eivya6943d36c6b8
diff --git a/server/services/browserService.js b/server/services/browserService.js
index 9cb62af672..185e31e05e 100644
--- a/server/services/browserService.js
+++ b/server/services/browserService.js
@@ -5,7 +5,7 @@
*/
import { readdir, stat, unlink } from 'fs/promises';
-import { join, basename, resolve, extname } from 'path';
+import { join, basename, dirname, resolve, extname } from 'path';
import { EventEmitter } from 'events';
import { ensureDir, safeJSONParse, PATHS, tryReadFile, atomicWrite, sleep } from '../lib/fileUtils.js';
import { normalizeBrowserConfig } from '../lib/browserConfig.js';
@@ -849,7 +849,7 @@ export async function resolveDownload(name) {
const safeName = basename(name || '');
if (!safeName || safeName.startsWith('.') || safeName.endsWith('.crdownload')) return null;
const absPath = resolve(downloadDir, safeName);
- if (!absPath.startsWith(downloadDir + '/')) return null;
+ if (dirname(absPath) !== downloadDir) return null;
const info = await stat(absPath).catch(() => null);
if (!info?.isFile()) return null;
const ext = extname(safeName).toLowerCase();
diff --git a/server/services/browserService.test.js b/server/services/browserService.test.js
index 38fa369a59..4844923ef4 100644
--- a/server/services/browserService.test.js
+++ b/server/services/browserService.test.js
@@ -820,7 +820,7 @@ describe('read-only browser observation', () => {
connected: true, pageCount: 1,
pages: [{ title: 'Example' }], downloads: { files: [{ name: 'example.txt' }] },
});
- await service.deleteDownload('example.txt');
+ expect(await service.deleteDownload('example.txt')).toBe(true);
expect(changed).toHaveBeenCalledOnce();
pageBody = { malformed: true };
await expect(service.getFullStatus({ strict: true })).rejects.toThrow('pages unavailable');