Merge pull request #1378 from akasha-scheuermann/fix/setup-preserve-mount-allowlist
fix: skip mount-allowlist write during setup if file already exists
This commit is contained in:
@@ -10,21 +10,23 @@ import { logger } from '../src/logger.js';
|
||||
import { isRoot } from './platform.js';
|
||||
import { emitStatus } from './status.js';
|
||||
|
||||
function parseArgs(args: string[]): { empty: boolean; json: string } {
|
||||
function parseArgs(args: string[]): { empty: boolean; json: string; force: boolean } {
|
||||
let empty = false;
|
||||
let json = '';
|
||||
let force = false;
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
if (args[i] === '--empty') empty = true;
|
||||
if (args[i] === '--force') force = true;
|
||||
if (args[i] === '--json' && args[i + 1]) {
|
||||
json = args[i + 1];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return { empty, json };
|
||||
return { empty, json, force };
|
||||
}
|
||||
|
||||
export async function run(args: string[]): Promise<void> {
|
||||
const { empty, json } = parseArgs(args);
|
||||
const { empty, json, force } = parseArgs(args);
|
||||
const homeDir = os.homedir();
|
||||
const configDir = path.join(homeDir, '.config', 'nanoclaw');
|
||||
const configFile = path.join(configDir, 'mount-allowlist.json');
|
||||
@@ -37,6 +39,21 @@ export async function run(args: string[]): Promise<void> {
|
||||
|
||||
fs.mkdirSync(configDir, { recursive: true });
|
||||
|
||||
if (fs.existsSync(configFile) && !force) {
|
||||
logger.info(
|
||||
{ configFile },
|
||||
'Mount allowlist already exists — skipping (use --force to overwrite)',
|
||||
);
|
||||
emitStatus('CONFIGURE_MOUNTS', {
|
||||
PATH: configFile,
|
||||
ALLOWED_ROOTS: 0,
|
||||
NON_MAIN_READ_ONLY: 'unknown',
|
||||
STATUS: 'skipped',
|
||||
LOG: 'logs/setup.log',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let allowedRoots = 0;
|
||||
let nonMainReadOnly = 'true';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user