[Unison-hackers] [unison-svn] r302 - trunk/src

Benjamin C. Pierce bcpierce at seas.upenn.edu
Wed Jul 2 10:06:12 EDT 2008


Author: bcpierce
Date: 2008-07-02 10:06:09 -0400 (Wed, 02 Jul 2008)
New Revision: 302

Modified:
   trunk/src/RECENTNEWS
   trunk/src/TODO.txt
   trunk/src/copy.ml
   trunk/src/mkProjectInfo.ml
   trunk/src/os.ml
   trunk/src/update.ml
Log:
* Fixed a couple of file-transfer bugs.  (One was about copying
  resource forks.  Another was about restarting interrupted transfers
  on files where exactly zero bytes had been transferred so far and
  the file had been created with null permissions -- believe it or
  not, this is possible with rsync!)  This required a protocol change,
  so I'm also bumping the version number.


Modified: trunk/src/RECENTNEWS
===================================================================
--- trunk/src/RECENTNEWS	2008-06-28 14:19:29 UTC (rev 301)
+++ trunk/src/RECENTNEWS	2008-07-02 14:06:09 UTC (rev 302)
@@ -1,3 +1,13 @@
+CHANGES FROM VERSION 2.31.-1
+
+* Fixed a couple of file-transfer bugs.  (One was about copying
+  resource forks.  Another was about restarting interrupted transfers
+  on files where exactly zero bytes had been transferred so far and
+  the file had been created with null permissions -- believe it or
+  not, this is possible with rsync!)  This required a protocol change,
+  so I'm also bumping the version number.
+
+-------------------------------
 CHANGES FROM VERSION 2.30.4
 
 * Work on text UI to prepare for new filesystem watcher functionality

Modified: trunk/src/TODO.txt
===================================================================
--- trunk/src/TODO.txt	2008-06-28 14:19:29 UTC (rev 301)
+++ trunk/src/TODO.txt	2008-07-02 14:06:09 UTC (rev 302)
@@ -13,8 +13,6 @@
 
 * Makefile for fstest
 
-* Reverse CheckNonemptyAndMakeWriteable 
-
 * Work on the Unison side
      - create temp file
      - start watcher based on watcherosx switch, passing all paths as args
@@ -30,7 +28,7 @@
        scratch if necessary
 
 * See if there are other hacks that should be propagated to 2.27 (the
-  directory transfer throttle for sure!)
+  directory transfer throttle for sure!), and Jerome's recent suggested fix
 
 
 ###########################################################################

Modified: trunk/src/copy.ml
===================================================================
--- trunk/src/copy.ml	2008-06-28 14:19:29 UTC (rev 301)
+++ trunk/src/copy.ml	2008-07-02 14:06:09 UTC (rev 302)
@@ -316,10 +316,11 @@
 let reallyTransferFile
     connFrom fspathFrom pathFrom fspathTo pathTo realPathTo
     update desc ressLength ressOnly id =
-  debug (fun() -> Util.msg "reallyTransferFile(%s,%s) -> (%s,%s,%s,%s)\n"
+  debug (fun() -> Util.msg "reallyTransferFile(%s,%s) -> (%s,%s,%s,%s)%s\n"
       (Fspath.toString fspathFrom) (Path.toString pathFrom)
       (Fspath.toString fspathTo) (Path.toString pathTo)
-      (Path.toString realPathTo) (Props.toString desc));
+      (Path.toString realPathTo) (Props.toString desc)
+      (if ressOnly then " (ONLY RESOURCE FORK)" else ""));
   let srcFileSize = Props.length desc in
   let file_id = Remote.newMsgId () in
 
@@ -547,20 +548,23 @@
 let targetExists checkSize fspathTo pathTo =
      Os.exists fspathTo pathTo
   && (match checkSize with
-        `CheckNonemptyAndMakeWriteable ->
+        `MakeWriteableAndCheckNonempty ->
+          let n = Fspath.concatToString fspathTo pathTo in
+          let perms = (Unix.stat n).Unix.st_perm in
+          let perms' = perms lor 0o600 in
+          Unix.chmod n perms';
           let r =
             Props.length (Fileinfo.get false fspathTo pathTo).Fileinfo.desc
               > Uutil.Filesize.zero in
-          if r then begin
-            let n = Fspath.concatToString fspathTo pathTo in
-            let perms = (Unix.stat n).Unix.st_perm in
-            let perms' = perms lor 0o600 in
-            Unix.chmod n perms'
-          end;
           r
-      | `CheckSize desc ->
-          Props.length (Fileinfo.get false fspathTo pathTo).Fileinfo.desc
-            = Props.length desc)
+      | `CheckDataSize desc ->
+             Props.length (Fileinfo.get false fspathTo pathTo).Fileinfo.desc
+               = Props.length desc
+      | `CheckSize (desc,ress) ->
+             Props.length (Fileinfo.get false fspathTo pathTo).Fileinfo.desc
+               = Props.length desc
+          && Osx.ressLength (Osx.getFileInfos fspathTo pathTo `FILE).Osx.ressInfo
+               = Osx.ressLength ress)
 
 let targetExistsLocal connFrom (checkSize, fspathTo, pathTo) =
   Lwt.return (targetExists checkSize fspathTo pathTo)
@@ -598,7 +602,7 @@
   else begin
     Uutil.showProgress id Uutil.Filesize.zero "ext";
     targetExistsOnRoot
-      rootTo rootFrom (`CheckNonemptyAndMakeWriteable, fspathTo, pathTo) >>= (fun b ->
+      rootTo rootFrom (`MakeWriteableAndCheckNonempty, fspathTo, pathTo) >>= (fun b ->
     let prog =
       if b
         then Prefs.read copyprogrest
@@ -621,11 +625,13 @@
                ^ (Os.quotes toSpec) in
     Trace.log (Printf.sprintf "%s\n" cmd);
     let _,log = Os.runExternalProgram cmd in
-    debug (fun() -> Util.msg
-             "transferFileUsingExternalCopyprog: returned\n------\n%s\n-----\n"
-               (Util.trimWhitespace log));
+    debug (fun() ->
+             let l = Util.trimWhitespace log in
+             Util.msg "transferFileUsingExternalCopyprog %s: returned...\n%s%s"
+               (Path.toString pathFrom)
+               l (if l="" then "" else "\n"));
     targetExistsOnRoot
-      rootTo rootFrom (`CheckSize desc, fspathTo, pathTo)
+      rootTo rootFrom (`CheckDataSize desc, fspathTo, pathTo)
         >>= (fun b ->
     if not b then
       raise (Util.Transient (Printf.sprintf
@@ -653,7 +659,7 @@
       (* Check whether we actually need to copy the file (or whether it
          already exists from some interrupted previous transfer) *)
       targetExistsOnRoot
-        rootTo rootFrom (`CheckSize desc, fspathTo, pathTo) >>= (fun b ->
+        rootTo rootFrom (`CheckSize (desc,ress), fspathTo, pathTo) >>= (fun b ->
       if b then begin
         Util.msg "%s/%s has already been transferred\n"
           (Fspath.toString fspathTo) (Path.toString pathTo);
@@ -663,9 +669,9 @@
       end else if
            Prefs.read copyprog <> ""
         && Prefs.read copythreshold >= 0
-        && Props.length desc >= Uutil.Filesize.ofInt64 (Int64.mul
-                                   (Int64.of_int 1000)
-                                   (Int64.of_int (Prefs.read copythreshold)))
+        && Props.length desc >= Uutil.Filesize.ofInt64
+                                   (Int64.mul (Int64.of_int 1000)
+                                     (Int64.of_int (Prefs.read copythreshold)))
         && update = `Copy
       then begin
         (* First use the external program to copy the data fork *)
@@ -674,13 +680,13 @@
           update desc fp ress id >>= (fun () ->
         (* Now use the regular transport mechanism to copy the resource
            fork *)
-        begin if (Osx.ressLength ress) > Uutil.Filesize.zero then
+        begin if (Osx.ressLength ress) > Uutil.Filesize.zero then begin
           transferFile
             rootFrom pathFrom rootTo fspathTo pathTo realPathTo
             update desc fp ress true id
-        else Lwt.return ()
+        end else Lwt.return ()
         end >>= (fun() ->
-        (* Finally, initialize the file info *)
+        (* Finally, set the file info *)
         setFileinfoOnRoot rootTo rootFrom (fspathTo, pathTo, desc)))
       end else
         (* Just transfer the file in the usual way with Unison's

Modified: trunk/src/mkProjectInfo.ml
===================================================================
--- trunk/src/mkProjectInfo.ml	2008-06-28 14:19:29 UTC (rev 301)
+++ trunk/src/mkProjectInfo.ml	2008-07-02 14:06:09 UTC (rev 302)
@@ -5,8 +5,8 @@
 
 let projectName = "unison"
 let majorVersion = 2
-let minorVersion = 30
-let pointVersionOrigin = 294 (* Revision that corresponds to point version 0 *)
+let minorVersion = 31
+let pointVersionOrigin = 301 (* Revision that corresponds to point version 0 *)
 
 (* Documentation:
    This is a program to construct a version of the form Major.Minor.Point,
@@ -86,3 +86,4 @@
 
 
 
+

Modified: trunk/src/os.ml
===================================================================
--- trunk/src/os.ml	2008-06-28 14:19:29 UTC (rev 301)
+++ trunk/src/os.ml	2008-07-02 14:06:09 UTC (rev 302)
@@ -404,7 +404,6 @@
          "") in
     (returnValue,mergeResultLog) 
   end else Lwt_unix.run (
-    debug (fun()-> Util.msg "Executing external program unix-style\n");
     Lwt_unix.open_process_full cmd (Unix.environment ()) 
     >>= (fun (out, ipt, err) ->
     readChannelsTillEof [out;err]

Modified: trunk/src/update.ml
===================================================================
--- trunk/src/update.ml	2008-06-28 14:19:29 UTC (rev 301)
+++ trunk/src/update.ml	2008-07-02 14:06:09 UTC (rev 302)
@@ -1742,7 +1742,7 @@
         let dig' = Os.fingerprint fspath path info in
         let ress' = Osx.stamp info.Fileinfo.osX in
         if dig' <> dig then begin
-          if deleteBadTempFiles then Os.delete fspath path;
+(*          if deleteBadTempFiles then Os.delete fspath path; *)
           raise (Util.Transient (Printf.sprintf
             "The file %s was incorrectly transferred  (fingerprint mismatch in %s)%s"
             (Path.toString path)



More information about the Unison-hackers mailing list