Bug 9212 - rsync loses track of files if differing directory prefixes are given
Summary: rsync loses track of files if differing directory prefixes are given
Status: RESOLVED FIXED
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 3.0.9
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-25 13:24 UTC by Michal Luscon (mail bounces back)
Modified: 2012-10-07 17:51 UTC (History)
0 users

See Also:


Attachments
patch (316 bytes, patch)
2012-10-02 09:01 UTC, Michal Luscon (mail bounces back)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Luscon (mail bounces back) 2012-09-25 13:24:32 UTC
Description of problem:
  If rsync is given a list of files containing differing relative directory
  prefixes, it will lose track of the source files.

Steps to Reproduce:
1. Setup:
  % mkdir /tmp/test
  % cd /tmp/test
  % mkdir -p c/d dest
  % touch a.c b.c c/d/e.c f.c

2. Rsync
  % rsync -av --update ./a.c ./b.c ./c/d/e.c ./f.c dest/
  sending incremental file list
  rsync: link_stat "/tmp/tvb-test/f.c" failed: No such file or directory (2)
  file has vanished: "/tmp/tvb-test/a.c"
  file has vanished: "/tmp/tvb-test/b.c"
  e.c

  sent 125 bytes  received 69 bytes  388.00 bytes/sec
  total size is 0  speedup is 0.00
  rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.8]

  The files have NOT vanished.  It is just that rsync has lost track of
  where they were.
  
You can find proposed patch in attachment.

This bugreport originates from https://bugzilla.redhat.com/show_bug.cgi?id=823088 .
Comment 1 Michal Luscon (mail bounces back) 2012-10-02 09:01:51 UTC
Created attachment 7977 [details]
patch
Comment 2 Wayne Davison 2012-10-07 17:51:22 UTC
Good catch -- the change_dir() routine was being too optimal after a change_dir() where CD_SKIP_CHDIR had been used.  Your fix works great, and is probably what packagers should snag for a 3.0.9 touch-up.

For the 3.1.0dev code, I decided to change the change_dir() routine itself so that it knows that a skip has been done and avoids a needed chdir when CD_NORMAL is requested.  It's a little more code, but will help ensure that any other (future?) uses of change_dir() with CD_SKIP_CHDIR don't run into the same issue.