fix: remove automatic orphaned directory cleanup on startup (#128) (#132)

This commit is contained in:
Chris Scott authored and GitHub committed 2026-02-14 08:46:57 -05:00
1 parent 67c750300c
commit 19963f579e
2 files changed
+1 -29

No files matched your search

+1 -5
View File
@@ -10,7 +10,7 @@ import { createIPCServer, type IPCServer } from './ipc/ipcServer'
import { GitAuthService } from './services/git-auth'
import { createSettingsRoutes } from './routes/settings'
import { createHealthRoutes } from './routes/health'
import { createTTSRoutes, cleanupExpiredCache } from './routes/tts'
import { createTTSRoutes, cleanupExpiredCache } from './routes/tts';
import { createSTTRoutes } from './routes/stt'
import { createFileRoutes } from './routes/files'
import { createProvidersRoutes } from './routes/providers'
@@ -27,7 +27,6 @@ import { sseAggregator } from './services/sse-aggregator'
import { ensureDirectoryExists, writeFileContent, fileExists, readFileContent } from './services/file-operations'
import { SettingsService } from './services/settings'
import { opencodeServerManager } from './services/opencode-single-server'
import { cleanupOrphanedDirectories } from './services/repo'
import { proxyRequest, proxyMcpAuthStart, proxyMcpAuthAuthenticate } from './services/proxy'
import { NotificationService } from './services/notification'
import { logger } from './utils/logger'
@@ -181,9 +180,6 @@ try {
await ensureDirectoryExists(getConfigPath())
logger.info('Workspace directories initialized')
await cleanupOrphanedDirectories(db)
logger.info('Orphaned directory cleanup completed')
await cleanupExpiredCache()
await ensureDefaultConfigExists()
-24
View File
@@ -710,30 +710,6 @@ function normalizeRepoUrl(url: string, preserveSSH: boolean = false): { url: str
}
}
export async function cleanupOrphanedDirectories(database: Database): Promise<void> {
try {
const reposPath = getReposPath()
await ensureDirectoryExists(reposPath)
const dirResult = await executeCommand(['ls', '-1'], reposPath).catch(() => '')
const directories = dirResult.split('\n').filter(d => d.trim())
if (directories.length === 0) {
return
}
const allRepos = db.listRepos(database)
const trackedPaths = new Set(allRepos.map(r => r.localPath.split('/').pop()))
const orphanedDirs = directories.filter(dir => !trackedPaths.has(dir))
for (const dir of orphanedDirs) {
await executeCommand(['rm', '-rf', dir], reposPath).catch(() => {})
}
} catch {
// Cleanup is best-effort
}
}
async function createWorktreeSafely(baseRepoPath: string, worktreePath: string, branch: string, env: Record<string, string>): Promise<void> {
const currentBranch = await safeGetCurrentBranch(baseRepoPath, env)
if (currentBranch === branch) {