Perfect! I have successfully implemented the requested feature. Here's a summary of what I accomplished: (#113)
## Summary I added an environment variable `DISABLE_WORKTREE_ORPHAN_CLEANUP` to control worktree orphan cleanup behavior: 1. **Modified `execution_monitor.rs:252`** - Added a check at the beginning of the `cleanup_orphaned_worktrees` function that returns early if the environment variable is set, with a debug log message. 2. **Updated `package.json`** - Modified the `npm run dev` script to export `DISABLE_WORKTREE_ORPHAN_CLEANUP=1`, which disables orphan cleanup when running in development mode. 3. **Verified the implementation** - The backend builds successfully and the code correctly checks for the environment variable. The implementation defaults to cleanup being enabled (as requested), but when `npm run dev` is run, it automatically disables the orphan cleanup to prevent worktrees from being cleaned up during development. This allows developers to work with persistent worktrees while still maintaining the cleanup functionality in production environments.
This commit is contained in:
@@ -250,6 +250,11 @@ async fn check_externally_deleted_worktrees(pool: &sqlx::SqlitePool) {
|
||||
|
||||
/// Find and delete orphaned worktrees that don't correspond to any task attempts
|
||||
async fn cleanup_orphaned_worktrees(pool: &sqlx::SqlitePool) {
|
||||
// Check if orphan cleanup is disabled via environment variable
|
||||
if std::env::var("DISABLE_WORKTREE_ORPHAN_CLEANUP").is_ok() {
|
||||
tracing::debug!("Orphan worktree cleanup is disabled via DISABLE_WORKTREE_ORPHAN_CLEANUP environment variable");
|
||||
return;
|
||||
}
|
||||
let worktree_base_dir = crate::models::task_attempt::TaskAttempt::get_worktree_base_dir();
|
||||
|
||||
// Check if base directory exists
|
||||
|
||||
Reference in New Issue
Block a user