fix(fs): tolerate EACCES on existing mkdir targets (#319)

Add mkdirSafe/mkdirSyncSafe helpers that swallow EACCES/EPERM when the
target directory already exists with execute permission, and route all
recursive mkdir call sites through them so pre-existing directories
owned by another user do not break backend startup, file ops, or repo
mirroring.
This commit is contained in:
Chris Scott authored and GitHub committed 2026-07-23 22:51:17 -04:00
1 parent 8a8bdc18b0
commit 87f3d7f230
22 files changed
+210 -46

No files matched your search

@@ -1,6 +1,7 @@
import { promises as fs } from 'fs'
import path from 'path'
import { logger } from '../utils/logger'
import { mkdirSafe } from '../utils/fs-safe'
const PLUGIN_FILENAME = 'ocm-gh-env.js'
@@ -48,7 +49,7 @@ export function getGhEnvPluginDir(configHome: string): string {
export async function installGhEnvPlugin(configHome: string): Promise<void> {
try {
const dir = getGhEnvPluginDir(configHome)
await fs.mkdir(dir, { recursive: true })
await mkdirSafe(dir)
await fs.writeFile(path.join(dir, PLUGIN_FILENAME), PLUGIN_SOURCE, 'utf-8')
} catch (error) {
logger.warn('Failed to install gh-env OpenCode plugin:', error)