mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-10-28 00:28:16 -04:00
fixed a nasty bug in the handling of the --delete option when there
are duplicate file names in the list of files to be transferred (eg. the user specifies the same file twice).
This commit is contained in:
1 parent
97d6916e2d
commit
d966ee254a
2 files changed
+29
-15
No files matched your search
@@ -560,22 +560,36 @@ int file_compare(struct file_struct *f1,struct file_struct *f2)
|
||||
}
|
||||
|
||||
|
||||
/* we need this function because of the silly way in which duplicate
|
||||
entries are handled in the file lists - we can't change this
|
||||
without breaking existing versions */
|
||||
static int flist_up(struct file_list *flist, int i)
|
||||
{
|
||||
while (!flist->files[i].name) i++;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
int flist_find(struct file_list *flist,struct file_struct *f)
|
||||
{
|
||||
int low=0,high=flist->count-1;
|
||||
int low=0,high=flist->count-1;
|
||||
|
||||
while (low != high) {
|
||||
int mid = (low+high)/2;
|
||||
int ret = file_compare(&flist->files[mid],f);
|
||||
if (ret == 0) return mid;
|
||||
if (ret > 0)
|
||||
high=mid;
|
||||
else
|
||||
low=mid+1;
|
||||
}
|
||||
if (file_compare(&flist->files[low],f) == 0)
|
||||
return low;
|
||||
return -1;
|
||||
if (flist->count <= 0) return -1;
|
||||
|
||||
while (low != high) {
|
||||
int mid = (low+high)/2;
|
||||
int ret = file_compare(&flist->files[flist_up(flist, mid)],f);
|
||||
if (ret == 0) return flist_up(flist, mid);
|
||||
if (ret > 0) {
|
||||
high=mid;
|
||||
} else {
|
||||
low=mid+1;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_compare(&flist->files[flist_up(flist,low)],f) == 0)
|
||||
return flist_up(flist,low);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -548,10 +548,10 @@ static void delete_files(struct file_list *flist)
|
||||
strncmp(flist->files[j].name,last_name, strlen(last_name))==0)
|
||||
continue;
|
||||
last_name = flist->files[j].name;
|
||||
if (!(local_file_list = send_file_list(-1,1,&last_name)))
|
||||
continue;
|
||||
if (verbose > 1)
|
||||
fprintf(FINFO,"deleting in %s\n", last_name);
|
||||
if (!(local_file_list = send_file_list(-1,1,&last_name)))
|
||||
return;
|
||||
|
||||
for (i=local_file_list->count-1;i>=0;i--) {
|
||||
if (!local_file_list->files[i].name) continue;
|
||||
|
||||
Reference in new issue
Block a user