Bug 5051 - --copy-dest copies should use a temporary file unless --inplace
Summary: --copy-dest copies should use a temporary file unless --inplace
Status: CLOSED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.0.0
Hardware: x86 Linux
: P3 minor (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-27 23:25 UTC by Matt McCutchen
Modified: 2008-07-26 10:17 UTC (History)
0 users

See Also:


Attachments
Attempt to implement temporary file usage, etc. (7.72 KB, patch)
2007-10-28 00:19 UTC, Matt McCutchen
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt McCutchen 2007-10-27 23:25:57 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.
Comment 1 Matt McCutchen 2007-10-28 00:19:02 UTC
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.
Comment 2 Wayne Davison 2007-10-29 15:49:14 UTC
Good idea.  Thanks for the cleanup patch too.  I've gone over it, made a few tweaks, and checked-in the result.