mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +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
@@ -26,6 +26,7 @@ import { writeFileContent } from './file-operations'
|
||||
import { getOrCreateInternalToken } from './internal-token'
|
||||
import { installGhEnvPlugin } from './opencode-gh-env-plugin'
|
||||
import { CredentialProvider } from './credential-provider'
|
||||
import { mkdirSafe } from '../utils/fs-safe'
|
||||
|
||||
|
||||
const MIN_OPENCODE_VERSION = '1.0.137'
|
||||
@@ -495,7 +496,7 @@ class OpenCodeServerManager {
|
||||
const packageJsonPath = path.join(binDir, 'package.json')
|
||||
|
||||
try {
|
||||
await fs.mkdir(binDir, { recursive: true })
|
||||
await mkdirSafe(binDir)
|
||||
|
||||
const packageJsonExists = await fs.access(packageJsonPath)
|
||||
.then(() => true)
|
||||
@@ -600,7 +601,7 @@ class OpenCodeServerManager {
|
||||
}
|
||||
}
|
||||
|
||||
await fs.mkdir(installDir, { recursive: true })
|
||||
await mkdirSafe(installDir)
|
||||
if (!await fs.access(path.join(installDir, 'package.json')).then(() => true).catch(() => false)) {
|
||||
const init = spawnSync('bun', ['init', '-y'], { cwd: installDir, encoding: 'utf8', timeout: 30000 })
|
||||
if (init.status !== 0) {
|
||||
|
||||
Reference in new issue
Block a user