changed the name of the temporary filename to include a leading . so
authorAndrew Tridgell <tridge@samba.org>
Sun, 10 May 1998 13:45:03 +0000 (13:45 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sun, 10 May 1998 13:45:03 +0000 (13:45 +0000)
that it appears hidden while being transferred. This should be useful
when using rsync for mirroring so users accessing via ftp don't get
confused by the temporary files.

rsync.c

diff --git a/rsync.c b/rsync.c
index 950d575..9d11b72 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -818,12 +818,6 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
       }
 
       /* open tmp file */
-      if (strlen(fname) > (MAXPATHLEN-8)) {
-       rprintf(FERROR,"filename too long\n");
-       if (buf) unmap_file(buf);
-       close(fd1);
-       continue;
-      }
       if (tmpdir) {
              char *f;
              f = strrchr(fname,'/');
@@ -831,9 +825,22 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
                      f = fname;
              else 
                      f++;
-             sprintf(fnametmp,"%s/%s.XXXXXX",tmpdir,f);
+             if (strlen(tmpdir)+strlen(f)+10 > MAXPATHLEN) {
+                     rprintf(FERROR,"filename too long\n");
+                     if (buf) unmap_file(buf);
+                     close(fd1);
+                     continue;
+             }
+             sprintf(fnametmp,"%s/.%s.XXXXXX",tmpdir,f);
       } else {
-             sprintf(fnametmp,"%s.XXXXXX",fname);
+             if (strlen(fname)+9 > MAXPATHLEN) {
+                     rprintf(FERROR,"filename too long\n");
+                     if (buf) unmap_file(buf);
+                     close(fd1);
+                     continue;
+             }
+
+             sprintf(fnametmp,".%s.XXXXXX",fname);
       }
       if (NULL == do_mktemp(fnametmp)) {
        rprintf(FERROR,"mktemp %s failed\n",fnametmp);