Skip to content

Conversation

@Lilianxr
Copy link
Collaborator

@Lilianxr Lilianxr commented Dec 17, 2025

To test:
Run oxen init and check the .oxen/config.toml to find the path in storage.settings is ".oxen/versions/files"

Summary by CodeRabbit

  • Refactor
    • Improved storage path handling so repository-relative paths are resolved consistently against the repo location.
    • Version storage initialization made more explicit and consistent across workflows, with clearer handling of local vs remote storage paths.
    • Storage configuration now validates and preserves computed paths when saving repository settings.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Walkthrough

The PR changes the create_version_store API to accept an explicit repo_dir: &Path parameter and updates all callers (prune, LocalRepository, etc.) to pass the repository path. Local storage path resolution was moved to use the supplied repo path for converting relative ".oxen" paths to absolute ones; other logic is preserved.

Changes

Cohort / File(s) Summary
Version Store API Signature Update
oxen-rust/src/lib/src/storage/version_store.rs
create_version_store signature changed to create_version_store(repo_dir: &Path, storage_opts: &StorageOpts); removed internal repo root computation; local storage path resolution now joins relative paths with repo_dir; constructs versions_dir and passes it to LocalVersionStore::new.
Repository Integration Updates
oxen-rust/src/lib/src/model/repository/local_repository.rs
Call sites updated to pass repository path (&repo.path / &self.path) to create_version_store in from_dir, init_version_store, init_default_version_store, and set_version_store; save method updated to compute and serialize storage path (relative→absolute handling) into a HashMap for storage settings and errors if path missing.
Version Pruning Update
oxen-rust/src/lib/src/core/v_latest/prune.rs
prune_versions updated to call create_version_store(&repo.path, &storage_opts) instead of the previous single-argument form.

Sequence Diagram(s)

(omitted — changes are API/instantiation and path-resolution updates without new multi-component control flows requiring visualization)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jcelliott
  • rpschoenburg

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main objective: changing the versions directory to use a relative path in config.toml, which aligns with the core changes across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/relative-version-path

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24d9397 and a5b55b4.

📒 Files selected for processing (1)
  • oxen-rust/src/lib/src/model/repository/local_repository.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • oxen-rust/src/lib/src/model/repository/local_repository.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test Suite / Test Suite (macos-latest)
  • GitHub Check: Test Suite / Test Suite (windows-latest)
  • GitHub Check: Test Suite / Test Suite (ubuntu-latest)
  • GitHub Check: Lint / Cargo check, format, clippy + Ruff

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
oxen-rust/src/lib/src/storage/version_store.rs (1)

218-224: Consider using a more robust relative path check.

The current implementation checks if path.starts_with(".oxen") to determine whether to resolve the path relative to repo_dir. However, PathBuf::starts_with checks path components, which means it would match paths like PathBuf::from(".oxen/versions/files") but not paths that have been canonicalized or normalized differently.

Consider using path.is_relative() for a more general and robust check, which would correctly handle any relative path regardless of whether it starts with ".oxen":

-            let versions_dir = if let Some(path) = &local_storage_opts.path {
-                if path.starts_with(".oxen") {
-                    // if the path is relative, convert to absolute path
-                    repo_dir.join(path)
-                } else {
-                    path.clone()
-                }
+            let versions_dir = if let Some(ref path) = local_storage_opts.path {
+                if path.is_relative() {
+                    // if the path is relative, convert to absolute path
+                    repo_dir.join(path)
+                } else {
+                    path.clone()
+                }
             } else {

This approach would correctly handle all relative paths (e.g., ".oxen/versions/files", "./data", "versions", etc.) while treating absolute paths uniformly.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0de033 and 24d9397.

📒 Files selected for processing (3)
  • oxen-rust/src/lib/src/core/v_latest/prune.rs (1 hunks)
  • oxen-rust/src/lib/src/model/repository/local_repository.rs (5 hunks)
  • oxen-rust/src/lib/src/storage/version_store.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-18T19:11:42.443Z
Learnt from: Lilianxr
Repo: Oxen-AI/Oxen PR: 146
File: oxen-rust/src/benches/oxen/download.rs:176-179
Timestamp: 2025-09-18T19:11:42.443Z
Learning: In oxen-rust/src/benches/oxen/download.rs, the setup_repo_for_download_benchmark function always stages files under a "files" directory structure in the repository, regardless of whether data_path is provided or not. The hardcoded Path::new("files") in the repositories::download call is correct because of this consistent setup.

Applied to files:

  • oxen-rust/src/lib/src/storage/version_store.rs
  • oxen-rust/src/lib/src/model/repository/local_repository.rs
🧬 Code graph analysis (3)
oxen-rust/src/lib/src/core/v_latest/prune.rs (2)
oxen-rust/src/lib/src/model/repository/local_repository.rs (1)
  • version_store (83-88)
oxen-rust/src/lib/src/storage/version_store.rs (1)
  • create_version_store (208-251)
oxen-rust/src/lib/src/storage/version_store.rs (3)
oxen-rust/src/lib/src/util/fs.rs (1)
  • oxen_hidden_dir (46-48)
oxen-rust/src/lib/src/model/repository/local_repository.rs (1)
  • new (128-155)
oxen-rust/src/lib/src/storage/local.rs (1)
  • new (31-35)
oxen-rust/src/lib/src/model/repository/local_repository.rs (2)
oxen-rust/src/lib/src/storage/version_store.rs (1)
  • create_version_store (208-251)
oxen-rust/src/lib/src/util/fs.rs (3)
  • is_relative_to_dir (1496-1555)
  • oxen_hidden_dir (46-48)
  • path_relative_to_dir (1384-1493)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test Suite / Test Suite (windows-latest)
  • GitHub Check: Test Suite / Test Suite (ubuntu-latest)
  • GitHub Check: Test Suite / Test Suite (macos-latest)
  • GitHub Check: Lint / Cargo check, format, clippy + Ruff
🔇 Additional comments (4)
oxen-rust/src/lib/src/core/v_latest/prune.rs (1)

284-284: LGTM! Signature update correctly applied.

The call to create_version_store has been updated to pass &repo.path as the first argument, matching the new function signature.

oxen-rust/src/lib/src/model/repository/local_repository.rs (2)

14-14: LGTM! HashMap import added for StorageConfig construction.

The HashMap import is necessary for constructing the settings field in the save method.


77-77: LGTM! All create_version_store calls updated consistently.

All call sites have been correctly updated to pass the repository path as the first argument, matching the new function signature.

Also applies to: 91-91, 102-102, 109-109

oxen-rust/src/lib/src/storage/version_store.rs (1)

209-209: LGTM! Function signature updated to enable relative path resolution.

The addition of the repo_dir parameter enables proper resolution of relative storage paths, which is the core objective of this PR.

Copy link
Collaborator

@rpschoenburg rpschoenburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I do agree with the coderabbit comment to remove the unwrap statement though, that should be cleaned up

@Lilianxr Lilianxr merged commit ff36ba9 into main Dec 23, 2025
5 checks passed
@Lilianxr Lilianxr deleted the fix/relative-version-path branch December 23, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants