Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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()
Expand Down
24 changes: 0 additions & 24 deletions backend/src/services/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down