mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
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:
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)
|
||||
|
||||
Reference in new issue
Block a user