aboutsummaryrefslogtreecommitdiff
path: root/Types/Remote.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-01 16:59:54 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-01 17:15:11 -0400
commit7225c2bfc0c7149e646fa9af998da983e3fa8bc8 (patch)
treea07f878efd0876f539e4c10a6572be001ef41189 /Types/Remote.hs
parent8c10f377146e6599054488f47a3a742f6a7c5ae2 (diff)
record transfer information on local git remotes
In order to record a semi-useful filename associated with the key, this required plumbing the filename all the way through to the remotes' storeKey and retrieveKeyFile. Note that there is potential for deadlock here, narrowly avoided. Suppose the repos are A and B. A sends file foo to B, and at the same time, B gets file foo from A. So, A locks its upload transfer info file, and then locks B's download transfer info file. At the same time, B is taking the two locks in the opposite order. This is only not a deadlock because the lock code does not wait, and aborts. So one of A or B's transfers will be aborted and the other transfer will continue. Whew!
Diffstat (limited to 'Types/Remote.hs')
-rw-r--r--Types/Remote.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/Types/Remote.hs b/Types/Remote.hs
index 9bac2ca0f..c7628165c 100644
--- a/Types/Remote.hs
+++ b/Types/Remote.hs
@@ -33,6 +33,9 @@ data RemoteTypeA a = RemoteType {
instance Eq (RemoteTypeA a) where
x == y = typename x == typename y
+{- A filename associated with a Key, for display to user. -}
+type AssociatedFile = Maybe FilePath
+
{- An individual remote. -}
data RemoteA a = Remote {
-- each Remote has a unique uuid
@@ -42,9 +45,9 @@ data RemoteA a = Remote {
-- Remotes have a use cost; higher is more expensive
cost :: Int,
-- Transfers a key to the remote.
- storeKey :: Key -> a Bool,
+ storeKey :: Key -> AssociatedFile -> a Bool,
-- retrieves a key's contents to a file
- retrieveKeyFile :: Key -> FilePath -> a Bool,
+ retrieveKeyFile :: Key -> AssociatedFile -> FilePath -> a Bool,
-- retrieves a key's contents to a tmp file, if it can be done cheaply
retrieveKeyFileCheap :: Key -> FilePath -> a Bool,
-- removes a key's contents