Enhance file handling in list_files.js and patch_files.js by auto-creating chroot directories, improving path normalization, and refining error handling for file operations.

This commit is contained in:
sebseb7
2025-08-11 17:51:28 +02:00
parent b26d0d3f7e
commit f21aa45065
2 changed files with 73 additions and 34 deletions

View File

@@ -132,9 +132,10 @@ export async function run(args) {
let chrootResolved;
try {
chrootResolved = path.resolve(chrootPath);
await fs.access(chrootResolved); // Ensure chroot path exists
// Auto-create the chroot base directory if it does not exist
await fs.mkdir(chrootResolved, { recursive: true });
} catch (err) {
return { err: `Invalid chroot path: ${chrootPath} (${err?.message || String(err)})` };
return { err: `Failed to prepare chroot path: ${chrootPath} (${err?.message || String(err)})` };
}
let resolvedBase;