Skip to content

Use mv_file for single-file moves - #2099

Draft
aryansk wants to merge 1 commit into
fsspec:masterfrom
aryansk:codex/issue-2017-mv-file
Draft

Use mv_file for single-file moves#2099
aryansk wants to merge 1 commit into
fsspec:masterfrom
aryansk:codex/issue-2017-mv-file

Conversation

@aryansk

@aryansk aryansk commented Aug 12, 2026

Copy link
Copy Markdown

Fixes #2017

Summary

  • add a default mv_file implementation that preserves the existing copy/delete behavior
  • route file-only moves through mv_file so filesystems can provide an atomic override
  • preserve recursive directory move behavior and add MemoryFileSystem regression coverage

Validation

  • ruff format fsspec/spec.py fsspec/implementations/tests/test_memory.py
  • ruff check fsspec/spec.py fsspec/implementations/tests/test_memory.py
  • pytest fsspec/implementations/tests/test_memory.py -q
  • pytest fsspec/tests/abstract/mv.py -q
  • git diff --check

Prepared with AI assistance; I reviewed the implementation and validation output.

@martindurant

Copy link
Copy Markdown
Member

I feel this might have been done - perhaps only for async? Or perhaps in a PR that hasn't been merged? Please check.

@aryansk

aryansk commented Aug 12, 2026

Copy link
Copy Markdown
Author

Thanks for flagging this. I checked current master: AsyncFileSystem._mv_file already exists, and GCSFS overrides it for its atomic move path, but synchronous AbstractFileSystem.mv still calls copy followed by rm and there is no corresponding sync mv_file hook.

This draft is the sync counterpart: file-only moves go through the new default mv_file (which preserves copy/delete behavior and can be overridden by a backend), while directory moves retain the existing recursive copy/remove path. The regression test verifies that mv calls an override. If you were referring to a pending sync implementation elsewhere, please point me to it and I'll compare.

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.

Use mv_file instead of copy + rm to implement mv

2 participants