[Unison-hackers] Does copyprog option do not work for local files?
Benjamin Pierce
bcpierce at cis.upenn.edu
Mon Mar 30 08:21:11 EDT 2009
OK, attached is a hacked version of copy.ml that uses copyprog also
for local transfers. It has been tested on exactly one example.
I'm afraid I won't be able to help any more with this -- there's a
long list of Unison things to be fixed and very limited time for
working on them. But I hope it gets you started.
Best,
- Benjamin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: copy.ml
Type: application/octet-stream
Size: 25790 bytes
Desc: not available
Url : http://lists.seas.upenn.edu/pipermail/unison-hackers/attachments/20090330/4ffa82da/copy.dll
-------------- next part --------------
On Mar 30, 2009, at 4:26 AM, netawater wrote:
> Benjamin Pierce <bcpierce at cis.upenn.edu> writes:
>
>> If you only care about the file contents (not permissions, etc.), you
>> should be able to replace the body of Copy.localFile with an
>> invocation of your external copy program by calling
>> External.runExternalProgram.
>>
>> However, depending on what you feel your time is worth, I wonder
>> whether just replacing the network drive with one that works might
>> not
>> be a better solution...
>>
>> Best,
>>
>> - Benjamin
>>
>>
>>
>> On Mar 29, 2009, at 3:37 AM, netawater wrote:
>>
>>> Alan Schmitt <alan.schmitt at polytechnique.org> writes:
>>>
>>>> On 28 mars 09, at 06:44, netawater wrote:
>>>>
>>>>> I try use unison to synchronize my files with copyprog option, I
>>>>> have set copythreshold = 0, but It seems unison does not call my
>>>>> copy program.
>>>>>
>>>>> I have studied the copy.ml, and found these expressions in file
>>>>> function
>>>>>
>>>>> match rootFrom, rootTo with
>>>>> (Common.Local, fspathFrom), (Common.Local, realFspathTo) ->
>>>>> localFile
>>>>> fspathFrom pathFrom fspathTo pathTo realPathTo
>>>>> update desc (Osx.ressLength ress) (Some id);
>>>>> Lwt.return ()
>>>>>
>>>>> It means if it found there are local files, it will call localFile
>>>>> function
>>>>> so that copyprog is ignored.
>>>>
>>>> Yes, it is correct. To be precise, copyprog is called:
>>>> - when one file is remote
>>>> - when the remote file is missing (i.e. it's a file creation, not a
>>>> file modification)
>>>> - when the remote file is bigger than the threshold.
>>>>
>>>> Alan
>>>> _______________________________________________
>>>> Unison-hackers mailing list
>>>> Unison-hackers at lists.seas.upenn.edu
>>>> http://lists.seas.upenn.edu/mailman/listinfo/unison-hackers
>>>
>>> Thanks for you reply.
>>>
>>> My situation is I want to synchronize my files from my local
>>> driver C:
>>> to a network driver \\Wua141699 in Windows. The network drive is not
>>> very stable and I need use my copy program to copy and verify files
>>> instead unison's native copy method.
>>>
>>> Can I make this happen? I have tried hard but I can not finish it.
>>>
>>> _______________________________________________
>>> Unison-hackers mailing list
>>> Unison-hackers at lists.seas.upenn.edu
>>> http://lists.seas.upenn.edu/mailman/listinfo/unison-hackers
>
> Thank you! My network drive is produced by Wuala and I like its p2p
> online storage, so I do not want to change it.
>
> I have tried modify localfile like this:
>
> let localFile
> (* fspathFrom pathFrom fspathTo pathTo realPathTo update desc
> ressLength ido =
> *)
> rootFrom pathFrom fspathTo pathTo realPathTo update desc
> ressLength ido =
> (* Plato Wu,2009/03/30: use External.runExternalProgram instead *)
> targetExistsLocal
> rootFrom (`MakeWriteableAndCheckNonempty, fspathTo, pathTo) >>=
> (fun b ->
> let prog =
> if b
> then Prefs.read copyprogrest
> else Prefs.read copyprog in
> let fromSpec =
> (formatConnectionInfo rootFrom)
> ^ (Fspath.concatToString (snd rootFrom) pathFrom) in
> let toSpec =
> (* (formatConnectionInfo rootTo) ^ *)
> (Fspath.concatToString fspathTo pathTo) in
> let cmd = prog ^ " "
> ^ (Os.quotes fromSpec) ^ " "
> ^ (Os.quotes toSpec) in
> Trace.log (Printf.sprintf "%s\n" cmd);
> let _,log = Os.runExternalProgram cmd in
> 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"));
> targetExistsLocal
> rootFrom (`CheckDataSize desc, fspathTo, pathTo)
>>> = (fun b ->
> if not b then
> raise (Util.Transient (Printf.sprintf
> "External copy program did not create target file (or bad
> length): %s"
> (Path.toString pathTo)));
> (* Uutil.showProgress id (Props.length desc) "ext"; *)
> Lwt.return (match update with
> `Update _ ->
> Fileinfo.set fspathTo pathTo (`Copy realPathTo) desc
> | `Copy ->
> Fileinfo.set fspathTo pathTo (`Set Props.fileDefault)
> desc) ));
>
> I know little about Ocaml's grammar and semantic, so I struggled in
> modification and compilation, can you help me to finish this function.
> Thank you very much!
>
> _______________________________________________
> Unison-hackers mailing list
> Unison-hackers at lists.seas.upenn.edu
> http://lists.seas.upenn.edu/mailman/listinfo/unison-hackers
More information about the Unison-hackers
mailing list