-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os: update mv fns, improve performance, add params struct to control overwrite behavior #20156
Conversation
1d9ebd6
to
4cdda23
Compare
I was wrong about the performance boost. When fixing So the PR would be about adding an overwrite params struct, and cleaning up |
758aeba
to
4d4a5ae
Compare
Co-authored-by: Delyan Angelov <26967+spytheman@users.noreply.github.com>
The
rename
command that is used as first attempt by theos.mv
function, fails when the target path exists, asrename
doesn't overwrite. Then it falls back to usingmv_by_cp
which does overwrite (means the current default behavior ofmv
is to overwrite viamv_by_cp
), butmv_by_cp
is less performant.Trying to use a consistent non-overwriting behavior would result in a breaking change.
Therefore, the PR leaves overwriting on by default - equivalent to the system command
mv
, but improves it's behavior to still userename
command when possible, and by allowing to disable overwriting via a params struct.That the fallback towards overwriting by
mv_by_cp
happens quite often, becomes noticeable when disabling overwriting. E.g. CI runs:outdated
A performance example: if the target directory already exists, falling back to
os.mv_by_cp
is already less than 100% performant when just wanting to move 2 1mb files.Current master:
PR changes:
The PR also does some other changes related to the
os.mv
command as incremental refactor.🤖[deprecated] Generated by Copilot at 4cdda23
Added an
overwrite
option toos.mv
andos.mv_by_cp
functions and improved their behavior across platforms and partitions. Simplified and fixed some tools that use these functions. Updated the corresponding test function.🤖[deprecated] Generated by Copilot at 4cdda23
overwrite
parameter toos.mv
andos.mv_by_cp
functions to control whether the target should be overwritten if it exists (link,link,link)vshader
andvpm
tools, sinceos.mv
handles cross-partition and cross-platform cases consistently (link,link)vbump
tool to say 'move' instead of 'copy' (link)