Skip to content

get_data_dir recreates a registered data dir that no longer exists, stranding the real graph #1057

Description

@Vex788

A repository registered with --data-dir pointing into a temp directory loses its graph when the OS sweeps that directory, and the failure is silent and self-perpetuating.

get_data_dir trusts the registry entry with no existence check. With create=True it does data_dir.mkdir(parents=True, exist_ok=True) on the registered path, so:

  1. The temp directory is swept.
  2. The next read-only tool resolves to the missing path and reports missing_graph / "No graph found ... run build first" — while a perfectly good <repo>/.code-review-graph/graph.db sits there unused.
  3. The next write command recreates the registered directory empty and builds a second graph into it.

_get_store in tools/_common.py calls get_db_path(root) without read_only=True, so even an ordinary query participates in step 3.

Suggested fix: when create=True, the registered directory does not exist, and <repo>/.code-review-graph/graph.db does, log a warning naming both paths and fall through to normal resolution instead of creating the registered path. Relocating a graph-less repository to a fresh directory — the documented use of --data-dir — keeps working because the guard only fires when a local graph already exists.

Related and cheap: code-review-graph repos prints only the repository path, so a relocated data_dir is invisible. Printing it, with a [MISSING] marker when the directory is gone, turns a silent failure into a visible one.

Activity

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