Skip to content

fix(File): fall back to copy+remove on cross-device rename (EXDEV) - #9207

Merged
timosachsenberg merged 2 commits into
developfrom
fix/file-rename-exdev
Apr 22, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
fix/file-rename-exdev

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

File::rename() now falls back to std::filesystem::copy_file + std::filesystem::remove when std::filesystem::rename fails with EXDEV (cross-device link). This restores the cross-filesystem semantics that QFile::rename provided before PR #8938 replaced Qt with std::filesystem.

Why

std::filesystem::rename follows POSIX rename(2) and fails with EXDEV when source and destination are on different mounts. QFile::rename (the pre-#8938 implementation) silently copied + removed in that case. The regression surfaced as:

Error: Could not move '/tmp/.../result.pin' to 'HepG2_rep1_small_pin.tsv'

…when running OpenMS TOPP tools inside a container where /tmp is on an overlay FS and the output dir is a bind mount.

Affected TOPP tools (all move files from tmp_dir.getPath() to a user-specified output):

  • CometAdapter -pin_out
  • MSGFPlusAdapter -mzid_out
  • MSFraggerAdapter (optional pepXML out, lower risk — source is typically next to the input mzML)

Since all three go through File::rename, fixing it once in File.cpp covers them all.

Behavior

  • Normal (same-FS) rename: unchanged — still an atomic std::filesystem::rename.
  • EXDEV: copy + best-effort source remove (matches Qt's documented fallback).
  • Any other rename error: unchanged — logged and returns false.

Test plan

  • File_test still passes (same-FS path unchanged).
  • Not unit-tested for the EXDEV branch — reproducing it requires two filesystems, which isn't available in the standard CI runner (/tmp and the build dir share a mount). The fix is narrow (the added if (rename_ec == std::errc::cross_device_link) block is ~17 lines) and relies on code review + downstream integration testing in the container environment that originally tripped the bug.
  • Nightly integration runs inside a container should now complete CometAdapter -pin_out without the "Could not move" error.

If desired, a follow-up could add an env-gated test (e.g. OPENMS_TEST_CROSSFS_DIR pointing at a path on a different mount) that runs only where a second filesystem is available.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • File rename and move operations now handle cross-filesystem scenarios, allowing successful transfers between different storage devices without errors.

timosachsenberg and others added 2 commits April 22, 2026 08:24
std::filesystem::rename fails with EXDEV across filesystems, unlike
Qt's QFile::rename which silently copied and removed. PR #8938 replaced
the Qt call without preserving that fallback, breaking TOPP adapters
(CometAdapter -pin_out, MSGFPlusAdapter -mzid_out) that move files from
a tmp dir to a bind-mounted output — a common container layout.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@timosachsenberg
timosachsenberg merged commit 7ffc651 into develop Apr 22, 2026
10 checks passed
@timosachsenberg
timosachsenberg deleted the fix/file-rename-exdev branch April 22, 2026 14:10
@coderabbitai

coderabbitai Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4d306a8-d84f-464b-94ce-832de7e83993

📥 Commits

Reviewing files that changed from the base of the PR and between 9a7f816 and b550738.

📒 Files selected for processing (1)
  • src/openms/source/SYSTEM/File.cpp

📝 Walkthrough

Walkthrough

Updated the OpenMS::File::rename() function to handle cross-device move operations. When std::filesystem::rename fails with a cross-device error, the function now falls back to copying the file to the destination and then removing the source file, with appropriate error handling for each operation.

Changes

Cohort / File(s) Summary
File System Operations
src/openms/source/SYSTEM/File.cpp
Enhanced rename() function with fallback mechanism for cross-device moves. When rename fails with cross_device_link error, copies file to destination then removes source, with error status updated based on copy operation success.

Poem

🐰 A file wants to cross the device line,
But rename says "no, that's not mine!"
So copy-then-delete saves the day,
Hops files across in a clever way! ✨

✨ 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 fix/file-rename-exdev

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.

timosachsenberg pushed a commit that referenced this pull request Apr 23, 2026
Restore ProSE/FragmentIndex/File entries dropped by the FeatureFinderCentroided
reorganization commit (#9159) and add new entries for commits merged after the
last sync:

- #9188: ProSE BREAKING: default isotope error range changed to [0,+2]
- #9191: ProSE SNES mother-peptide indexing for non-specific searches
- #9195: ProSE fix: defer PSM FDR when Percolator enabled; valid .pin output
- #9203: FragmentIndex: fixed bucket_size 4096 for tighter candidate lists
- #9204: ProSE: resolve PercolatorAdapter via findSiblingTOPPExecutable
- #9205: ProSE: per-file output isolation + dangling decoy ref crash fix
- #9207: File::rename: cross-device fallback (copy+remove on EXDEV)

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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.

1 participant