Skip to content

Commit

Permalink
Relaxed absolute path as key requirement in configure
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Nov 21, 2024
1 parent 3c1ae09 commit 5c08807
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { DeviceFS } from './devices.js';
import * as cache from './emulation/cache.js';
import { config } from './emulation/config.js';
import * as fs from './emulation/index.js';
import type { AbsolutePath } from './emulation/path.js';
import { Errno, ErrnoError } from './error.js';
import { FileSystem } from './filesystem.js';

Expand Down Expand Up @@ -68,8 +67,11 @@ export async function resolveMountConfig<T extends Backend>(configuration: Mount
return mount;
}

/**
* An object mapping mount points to backends
*/
export interface ConfigMounts {
[K: AbsolutePath]: Backend;
[K: string]: Backend;
}

/**
Expand All @@ -79,7 +81,7 @@ export interface Configuration<T extends ConfigMounts> extends SharedConfig {
/**
* An object mapping mount points to mount configuration
*/
mounts: { [K in keyof T & AbsolutePath]: MountConfiguration<T[K]> };
mounts: { [K in keyof T]: MountConfiguration<T[K]> };

/**
* The uid to use
Expand Down Expand Up @@ -200,10 +202,8 @@ export async function configure<T extends ConfigMounts>(configuration: Partial<C
const toMount: [string, FileSystem][] = [];
let unmountRoot = false;

for (const [point, mountConfig] of Object.entries(configuration.mounts)) {
if (!point.startsWith('/')) {
throw new ErrnoError(Errno.EINVAL, 'Mount points must have absolute paths');
}
for (const [_point, mountConfig] of Object.entries(configuration.mounts)) {
const point = _point.startsWith('/') ? _point : '/' + _point;

if (isBackendConfig(mountConfig)) {
mountConfig.disableAsyncCache ??= configuration.disableAsyncCache || false;
Expand Down

0 comments on commit 5c08807

Please sign in to comment.