The Samba-Bugzilla – Bug 5051
--copy-dest copies should use a temporary file unless --inplace
Last modified: 2008-07-26 10:17:46 UTC
Currently, --copy-dest local copies use copy_file(), which writes the destination file at its final name. I think these copies should use a temporary file unless --inplace is given, just like ordinary file transfers. Users who have a program that watches the destination and processes non-temporary files when they appear will appreciate this.
Created attachment 2956 [details]
Attempt to implement temporary file usage, etc.
In this patch I did the following:
- Factored out temporary file creation code from recv_files -> open_tmpfile
- Took the opportunity to reduce code duplication in recv_files
- Added an argument to copy_file to make it write to an existing fd instead of opening its own; updated existing calls
- Wrote new logic for local copies in do_local_copy, using open_tmpfile and the new copy_file mode when !inplace
- Took the opportunity to implement cleanup for partially written local-copy targets
This patch is a first draft; it seems to work, but it could probably use further testing and cleanup.
Good idea. Thanks for the cleanup patch too. I've gone over it, made a few tweaks, and checked-in the result.