Bug 8478 - Add an option to skip open files
Summary: Add an option to skip open files
Status: NEW
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.0.8
Hardware: All Windows 2008 R2
: P5 enhancement (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
Depends on:
Reported: 2011-09-22 22:59 UTC by Devin Nate
Modified: 2011-09-26 23:28 UTC (History)
0 users

See Also:

patch to skip open files (2.52 KB, application/octet-stream)
2011-09-22 22:59 UTC, Devin Nate
no flags Details
second version of patch (4.87 KB, patch)
2011-09-26 23:15 UTC, Devin Nate
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Nate 2011-09-22 22:59:41 UTC
Created attachment 6932 [details]
patch to skip open files

Add an option to skip files that are open on the sender.

use case is where syncing a directory with --remove-source-files and a prior patch I've written, for rename existing. It causes rsync to skip files on the sender that are open. Tested where cygwin/Windows is the sender. Not tested on other systems.
Comment 1 Devin Nate 2011-09-26 23:15:26 UTC
Created attachment 6950 [details]
second version of patch

Second version of the patch. I should note this is a very cygwin specific patch, and designed as such. I'd be surprised if this is of any value on a Unix/Linux system. Nevertheless, it does what we need, and I've seen some google requests for it, so it is contributed back. I wouldn't expect it to hit mainline rsync.

Basically, in cygwin, if a file is not-unlinkable, then a freshly created link() to that file is equally un-linkable. This patch sets up a directory (.rsync-tmp) and prior to processing any file creates a link(), then attempts an unlink(). If anything fails, it skips. Linux does not exhibit this behavior.

Also, for extra safety, it performs a flock() to get an exclusive lock, then immediately unlocks.