summaryrefslogtreecommitdiff
path: root/Creds.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-11-20 16:43:58 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-11-20 16:43:58 -0400
commit0d378285e709833f87547fd6fedc4e8b2f4884c4 (patch)
tree6caa2c4ba7710c917751d26c5bf58cce2a1163e2 /Creds.hs
parentcba848b472a4ac323693b44fcef9ddbbe535c929 (diff)
Amazon Glacier special remote; 100% working
Diffstat (limited to 'Creds.hs')
-rw-r--r--Creds.hs20
1 files changed, 17 insertions, 3 deletions
diff --git a/Creds.hs b/Creds.hs
index dbd05e3ef..f5ea55000 100644
--- a/Creds.hs
+++ b/Creds.hs
@@ -34,7 +34,7 @@ data CredPairStorage = CredPairStorage
{- Stores creds in a remote's configuration, if the remote allows
- that. Otherwise, caches them locally. -}
setRemoteCredPair :: RemoteConfig -> CredPairStorage -> Annex RemoteConfig
-setRemoteCredPair c storage = go =<< getRemoteCredPair c storage
+setRemoteCredPair c storage = go =<< getRemoteCredPair' c storage
where
go (Just creds)
| embedCreds c = case credPairRemoteKey storage of
@@ -58,8 +58,20 @@ setRemoteCredPair c storage = go =<< getRemoteCredPair c storage
{- Gets a remote's credpair, from the environment if set, otherwise
- from the cache in gitAnnexCredsDir, or failing that, from the
- value in RemoteConfig. -}
-getRemoteCredPair :: RemoteConfig -> CredPairStorage -> Annex (Maybe CredPair)
-getRemoteCredPair c storage = maybe fromcache (return . Just) =<< fromenv
+getRemoteCredPair :: String -> RemoteConfig -> CredPairStorage -> Annex (Maybe CredPair)
+getRemoteCredPair this c storage = maybe missing (return . Just) =<< getRemoteCredPair' c storage
+ where
+ (loginvar, passwordvar) = credPairEnvironment storage
+ missing = do
+ warning $ unwords
+ [ "Set both", loginvar
+ , "and", passwordvar
+ , "to use", this
+ ]
+ return Nothing
+
+getRemoteCredPair' :: RemoteConfig -> CredPairStorage -> Annex (Maybe CredPair)
+getRemoteCredPair' c storage = maybe fromcache (return . Just) =<< fromenv
where
fromenv = liftIO $ getEnvCredPair storage
fromcache = maybe fromconfig (return . Just) =<< readCacheCredPair storage
@@ -91,6 +103,8 @@ getEnvCredPair storage = liftM2 (,)
(uenv, penv) = credPairEnvironment storage
get = catchMaybeIO . getEnv
+
+
{- Stores a CredPair in the environment. -}
setEnvCredPair :: CredPair -> CredPairStorage -> IO ()
setEnvCredPair (l, p) storage = do