Skip to content

Data-loss risk: orphan cleanup deletes bind-mounted repos #128

Closed

Description

@GammelSami

When mounting a host directory into /workspace/repos/..., OpenCode Manager startup cleanup removed that directory as "orphaned", causing data loss.

Suspected code

  • backend/src/services/repo.ts (cleanupOrphanedDirectories)
  • called from backend/src/index.ts

Expected

  • never rm -rf unknown dirs by default or without asking
  • protect bind mounts/external dirs
  • make cleanup opt-in (env flag) or dry-run first?
  • aks user if they wanna add the new detected folder as a repo

I don't understand why a Docker named volume is the default for project directories, since it's impractical for common development workflows where you need to test locally on the host before committing; I had to add my project folder first via UI and then bind-mount ~/workspaces:/workspace.

Activity

  1. theepicsaxguy commented on Feb 14, 2026

    @theepicsaxguy
    Contributor

    Good findings! I guess this was done to support container installs.

    To support local and container maybe we could go with something like:

    Mount detection: Use stat to check if a directory's device differs from the repos base directory (bind mounts = different device). Mounted dirs get protection.

    Two-tier cleanup:

    Internal-created (same filesystem, OpenCode-owned): Safe to clean

    External-mounted (different filesystem, user-owned): Never touch

    Opt-in required: Disable all cleanup by default. Users who want automatic cleanup (contained installs) explicitly enable it.

  2. chriswritescode-dev commented on Feb 14, 2026

    @chriswritescode-dev
    Owner

    Yes, I believe this was before the File management and file browser. I just decided to remove it all together. Doesn't make a whole lot of sense. The user could always go in and browse the workspace and clean up any directories.

  3. chriswritescode-dev commented on Mar 21, 2026

    @chriswritescode-dev
    Owner

    #161 - resolved , new method of use added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions