Skip to content

Feature: Improve conflict resolution - #356

Open
infeo wants to merge 3 commits into
developfrom
feature/355-improve-conflict-resolution
Open

Feature: Improve conflict resolution#356
infeo wants to merge 3 commits into
developfrom
feature/355-improve-conflict-resolution

Conversation

@infeo

@infeo infeo commented Aug 6, 2026

Copy link
Copy Markdown
Member

Closes #355.

This PR refactors conflict resolution done in C9rConlictResolver.java, mainly the "trivial" case.

The most important change is, that conflict resolution is now skipped if affected resources are in a transient state. (i.e. dir.c9rnot written yet). Other changes focused on reducing io calls and basing resolution decisions after reading the state once to mitigate TOCTOU bugs.

@infeo infeo added this to the next milestone Aug 6, 2026
@infeo infeo self-assigned this Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 10682735-3980-4cb3-9982-3735713aebb3

📥 Commits

Reviewing files that changed from the base of the PR and between 355be01 and 1d13ffd.

📒 Files selected for processing (2)
  • src/main/java/org/cryptomator/cryptofs/dir/C9rConflictResolver.java
  • src/test/java/org/cryptomator/cryptofs/dir/C9rConflictResolverTest.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/test/java/org/cryptomator/cryptofs/dir/C9rConflictResolverTest.java
  • src/main/java/org/cryptomator/cryptofs/dir/C9rConflictResolver.java

Walkthrough

C9rConflictResolver now compares directory and symlink markers before resolving conflicts. Identical directories are deleted. Different or known types are renamed. Incomplete marker data postpones resolution. Bounded channel reads handle missing files and trailing bytes. Tests cover duplicate directories, differing IDs, incomplete copies, eventual resolution, and symlink-directory conflicts.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: improved conflict resolution.
Description check ✅ Passed The description accurately explains deferred resolution for transient resources and reduced I/O to address the conflict-resolution issue.
Linked Issues check ✅ Passed The changes defer incomplete directory-ID decisions and prevent duplicate directory links, satisfying issue #355.
Out of Scope Changes check ✅ Passed The implementation and tests remain focused on conflict resolution, directory-ID handling, transient state, and related I/O behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/355-improve-conflict-resolution

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/org/cryptomator/cryptofs/dir/C9rConflictResolver.java`:
- Around line 244-250: Update compareTypeFile to treat DIR_FILE_NAME markers as
comparable only when readUpTo returns at least Constants.MAX_DIR_ID_LENGTH
bytes, while preserving the existing non-empty check for other type files and
allowing trailing bytes. Add a regression test covering a non-empty partial
directory ID and verify the incomplete duplicate is deferred rather than
renamed.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0faa6975-fcc5-4524-bee3-a64966df0bf6

📥 Commits

Reviewing files that changed from the base of the PR and between 64de305 and 355be01.

📒 Files selected for processing (2)
  • src/main/java/org/cryptomator/cryptofs/dir/C9rConflictResolver.java
  • src/test/java/org/cryptomator/cryptofs/dir/C9rConflictResolverTest.java

Comment thread src/main/java/org/cryptomator/cryptofs/dir/C9rConflictResolver.java Outdated
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.

Automatic conflict resolution might create directoy link with already existing dirId

1 participant