On Thu, Sep 25, 2008 at 10:56:24 -0400, David Roundy wrote:
> Here's a fix for issue1003.  It was a pretty simple bug, in which we
> made the mistake of treating the first file specially.  The fix is
> simple enough that it should be pretty easy to review.

This patch looks fine, thanks!

Now I think I understand the SSH code better.  My mistake was in
assuming that we did not handle the case of the remote end reporting a
missing file.  I am pleased that no modifications need be made to darcs
transfer-mode.

1. Looking closer, I see that grabSSH (which actually fetches the file
   via transfer-mode), I see that we debugFail if darcs transfer-mode
   on the other end returns an error string.  We only sever the
   connection if we do not understand the error, for example if one day
   darcs transfer-mode starts saying fancy things.

2. Darcs.Repository.Format catches exceptions when trying
   to fetch "_darcs/format", just returning an empty file.

3. Not sure how #1 fits into #2?  Here is one missing piece of the
   puzzle.  Until today, I did not realise that IO fail throws an
   exception.  For some reason, I thought it just meant that subsequent
   IO actions were also failures, but I suppose I must have been
   thinking of the Maybe monad, a whole different creature.

   -- try this to see what I mean
   main = do fail "hello" `catch` \e -> putStrLn $ "look at: " ++ show e

Eric tries to understand
------------------------
Before, the function withSSHConnection would catch exceptions that are
raised (a) when launching darcs transfer-mode and (b) when the
withconnection action fails.  Keep in mind that every time we fetch a
file, we call withSSHConnection, potentially starting up darcs
transfer-mode.

David's patch runs the withconnection action outside of the try block
so that only exceptions in starting transfer-mode are caught.  This
does what we want because grabSSH itself knows how to handle fetch
failures (and they typically do not involve severing the connection).

Now the withaction job has the full responsibility for severing the
connection itself if something goes badly wrong.  But this is not an
issue, since withSSHConnection exists only for the copySSH(s) functions.

Oh and another useful thing for me to understand is that
severSSHConnection doesn't actually "do" anything.  It just makes a note
in sshConnections that there the url in question is associated with
(Just Nothing) so that subsequent attempts at fetching something from
that url do not attempt to use transfer-mode.

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9

Attachment: signature.asc
Description: Digital signature

_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to