Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed a bug in the handling of -R with --delete
[rsync/rsync.git]
/
rsync.c
diff --git
a/rsync.c
b/rsync.c
index
82035f5
..
c1ce0b5
100644
(file)
--- a/
rsync.c
+++ b/
rsync.c
@@
-93,7
+93,7
@@
static int delete_file(char *fname)
}
if (do_rmdir(fname) == 0 || errno == ENOENT) return 0;
}
if (do_rmdir(fname) == 0 || errno == ENOENT) return 0;
- if (!force_delete ||
errno != ENOTEMPTY
) {
+ if (!force_delete ||
(errno != ENOTEMPTY && errno != EEXIST)
) {
fprintf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno));
return -1;
}
fprintf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno));
return -1;
}
@@
-384,10
+384,10
@@
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
}
statret = -1;
}
}
statret = -1;
}
- if (statret != 0 && mkdir(fname,file->mode) != 0 && errno != EEXIST) {
+ if (statret != 0 &&
do_
mkdir(fname,file->mode) != 0 && errno != EEXIST) {
if (!(relative_paths && errno==ENOENT &&
create_directory_path(fname)==0 &&
if (!(relative_paths && errno==ENOENT &&
create_directory_path(fname)==0 &&
- mkdir(fname,file->mode)==0)) {
+
do_
mkdir(fname,file->mode)==0)) {
fprintf(FERROR,"mkdir %s : %s (2)\n",
fname,strerror(errno));
}
fprintf(FERROR,"mkdir %s : %s (2)\n",
fname,strerror(errno));
}
@@
-561,7
+561,7
@@
static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
sum_update(data,i);
sum_update(data,i);
- if (fd != -1 && write_
spars
e(fd,data,i) != i) {
+ if (fd != -1 && write_
fil
e(fd,data,i) != i) {
fprintf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
exit_cleanup(1);
}
fprintf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
exit_cleanup(1);
}
@@
-582,7
+582,7
@@
static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname)
see_token(map, len);
sum_update(map,len);
see_token(map, len);
sum_update(map,len);
- if (fd != -1 && write_
spars
e(fd,map,len) != len) {
+ if (fd != -1 && write_
fil
e(fd,map,len) != len) {
fprintf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
exit_cleanup(1);
}
fprintf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
exit_cleanup(1);
}
@@
-618,7
+618,7
@@
static void delete_one(struct file_struct *f)
}
} else {
if (do_rmdir(f_name(f)) != 0) {
}
} else {
if (do_rmdir(f_name(f)) != 0) {
- if (errno != ENOTEMPTY)
+ if (errno != ENOTEMPTY
&& errno != EEXIST
)
fprintf(FERROR,"rmdir %s : %s\n",f_name(f),strerror(errno));
} else if (verbose) {
fprintf(FINFO,"deleting directory %s\n",f_name(f));
fprintf(FERROR,"rmdir %s : %s\n",f_name(f),strerror(errno));
} else if (verbose) {
fprintf(FINFO,"deleting directory %s\n",f_name(f));
@@
-649,6
+649,8
@@
static int delete_already_done(struct file_list *flist,int j)
exit_cleanup(1);
}
exit_cleanup(1);
}
+ name[strlen(name)-2] = 0;
+
p = strrchr(name,'/');
if (!p) {
free(name);
p = strrchr(name,'/');
if (!p) {
free(name);
@@
-656,6
+658,8
@@
static int delete_already_done(struct file_list *flist,int j)
}
*p = 0;
}
*p = 0;
+ strcat(name,"/.");
+
while (low != high) {
int mid = (low+high)/2;
int ret = strcmp(f_name(flist->files[flist_up(flist, mid)]),name);
while (low != high) {
int mid = (low+high)/2;
int ret = strcmp(f_name(flist->files[flist_up(flist, mid)]),name);
@@
-703,6
+707,8
@@
static void delete_files(struct file_list *flist)
if (!S_ISDIR(flist->files[j]->mode)) continue;
if (!S_ISDIR(flist->files[j]->mode)) continue;
+ if (strlen(name)<2 || strcmp(name+strlen(name)-2,"/.")!=0) continue;
+
if (delete_already_done(flist, j)) continue;
if (!(local_file_list = send_file_list(-1,1,&name)))
if (delete_already_done(flist, j)) continue;
if (!(local_file_list = send_file_list(-1,1,&name)))
@@
-834,7
+840,7
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
} else {
sprintf(fnametmp,"%s.XXXXXX",fname);
}
} else {
sprintf(fnametmp,"%s.XXXXXX",fname);
}
- if (NULL == mktemp(fnametmp)) {
+ if (NULL ==
do_
mktemp(fnametmp)) {
fprintf(FERROR,"mktemp %s failed\n",fnametmp);
receive_data(f_in,buf,-1,NULL);
if (buf) unmap_file(buf);
fprintf(FERROR,"mktemp %s failed\n",fnametmp);
receive_data(f_in,buf,-1,NULL);
if (buf) unmap_file(buf);
@@
-878,14
+884,14
@@
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
continue;
}
sprintf(fnamebak,"%s%s",fname,backup_suffix);
continue;
}
sprintf(fnamebak,"%s%s",fname,backup_suffix);
- if (rename(fname,fnamebak) != 0 && errno != ENOENT) {
+ if (
do_
rename(fname,fnamebak) != 0 && errno != ENOENT) {
fprintf(FERROR,"rename %s %s : %s\n",fname,fnamebak,strerror(errno));
continue;
}
}
/* move tmp file over real file */
fprintf(FERROR,"rename %s %s : %s\n",fname,fnamebak,strerror(errno));
continue;
}
}
/* move tmp file over real file */
- if (rename(fnametmp,fname) != 0) {
+ if (
do_
rename(fnametmp,fname) != 0) {
if (errno == EXDEV) {
/* rename failed on cross-filesystem link.
Copy the file instead. */
if (errno == EXDEV) {
/* rename failed on cross-filesystem link.
Copy the file instead. */