Skip to content

Commit 19963f5

Browse files
fix: remove automatic orphaned directory cleanup on startup (#128) (#132)
1 parent 67c7503 commit 19963f5

2 files changed

Lines changed: 1 addition & 29 deletions

File tree

backend/src/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { createIPCServer, type IPCServer } from './ipc/ipcServer'
1010
import { GitAuthService } from './services/git-auth'
1111
import { createSettingsRoutes } from './routes/settings'
1212
import { createHealthRoutes } from './routes/health'
13-
import { createTTSRoutes, cleanupExpiredCache } from './routes/tts'
13+
import { createTTSRoutes, cleanupExpiredCache } from './routes/tts';
1414
import { createSTTRoutes } from './routes/stt'
1515
import { createFileRoutes } from './routes/files'
1616
import { createProvidersRoutes } from './routes/providers'
@@ -27,7 +27,6 @@ import { sseAggregator } from './services/sse-aggregator'
2727
import { ensureDirectoryExists, writeFileContent, fileExists, readFileContent } from './services/file-operations'
2828
import { SettingsService } from './services/settings'
2929
import { opencodeServerManager } from './services/opencode-single-server'
30-
import { cleanupOrphanedDirectories } from './services/repo'
3130
import { proxyRequest, proxyMcpAuthStart, proxyMcpAuthAuthenticate } from './services/proxy'
3231
import { NotificationService } from './services/notification'
3332
import { logger } from './utils/logger'
@@ -181,9 +180,6 @@ try {
181180
await ensureDirectoryExists(getConfigPath())
182181
logger.info('Workspace directories initialized')
183182

184-
await cleanupOrphanedDirectories(db)
185-
logger.info('Orphaned directory cleanup completed')
186-
187183
await cleanupExpiredCache()
188184

189185
await ensureDefaultConfigExists()

backend/src/services/repo.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -710,30 +710,6 @@ function normalizeRepoUrl(url: string, preserveSSH: boolean = false): { url: str
710710
}
711711
}
712712

713-
export async function cleanupOrphanedDirectories(database: Database): Promise<void> {
714-
try {
715-
const reposPath = getReposPath()
716-
await ensureDirectoryExists(reposPath)
717-
718-
const dirResult = await executeCommand(['ls', '-1'], reposPath).catch(() => '')
719-
const directories = dirResult.split('\n').filter(d => d.trim())
720-
721-
if (directories.length === 0) {
722-
return
723-
}
724-
725-
const allRepos = db.listRepos(database)
726-
const trackedPaths = new Set(allRepos.map(r => r.localPath.split('/').pop()))
727-
const orphanedDirs = directories.filter(dir => !trackedPaths.has(dir))
728-
729-
for (const dir of orphanedDirs) {
730-
await executeCommand(['rm', '-rf', dir], reposPath).catch(() => {})
731-
}
732-
} catch {
733-
// Cleanup is best-effort
734-
}
735-
}
736-
737713
async function createWorktreeSafely(baseRepoPath: string, worktreePath: string, branch: string, env: Record<string, string>): Promise<void> {
738714
const currentBranch = await safeGetCurrentBranch(baseRepoPath, env)
739715
if (currentBranch === branch) {

0 commit comments

Comments
 (0)