summaryrefslogtreecommitdiff
path: root/Remote/WebDAV.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-11-30 00:55:59 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-11-30 00:55:59 -0400
commit3026baf7ba4941029f3fb50888b3fd3290f720d1 (patch)
treedf34479c82189dde4d65453ee08a8195fb1bca59 /Remote/WebDAV.hs
parentdf31307f2ce1b037b68f16f9cb0187cf1e3a7b6d (diff)
avoid unnecessary Maybe
Diffstat (limited to 'Remote/WebDAV.hs')
-rw-r--r--Remote/WebDAV.hs61
1 files changed, 28 insertions, 33 deletions
diff --git a/Remote/WebDAV.hs b/Remote/WebDAV.hs
index a5bba716b..d6fc35f2e 100644
--- a/Remote/WebDAV.hs
+++ b/Remote/WebDAV.hs
@@ -45,34 +45,31 @@ remote = RemoteType {
setup = webdavSetup
}
-gen :: Git.Repo -> UUID -> Maybe RemoteConfig -> Annex Remote
-gen r u c = do
- cst <- remoteCost r expensiveRemoteCost
- return $ gen' r u c cst
-gen' :: Git.Repo -> UUID -> Maybe RemoteConfig -> Int -> Remote
-gen' r u c cst =
- encryptableRemote c
+gen :: Git.Repo -> UUID -> RemoteConfig -> Annex Remote
+gen r u c = new <$> remoteCost r expensiveRemoteCost
+ where
+ new cst = encryptableRemote c
(storeEncrypted this)
(retrieveEncrypted this)
this
- where
- this = Remote {
- uuid = u,
- cost = cst,
- name = Git.repoDescribe r,
- storeKey = store this,
- retrieveKeyFile = retrieve this,
- retrieveKeyFileCheap = retrieveCheap this,
- removeKey = remove this,
- hasKey = checkPresent this,
- hasKeyCheap = False,
- whereisKey = Nothing,
- config = c,
- repo = r,
- localpath = Nothing,
- readonly = False,
- remotetype = remote
- }
+ where
+ this = Remote {
+ uuid = u,
+ cost = cst,
+ name = Git.repoDescribe r,
+ storeKey = store this,
+ retrieveKeyFile = retrieve this,
+ retrieveKeyFileCheap = retrieveCheap this,
+ removeKey = remove this,
+ hasKey = checkPresent this,
+ hasKeyCheap = False,
+ whereisKey = Nothing,
+ config = c,
+ repo = r,
+ localpath = Nothing,
+ readonly = False,
+ remotetype = remote
+ }
webdavSetup :: UUID -> RemoteConfig -> Annex RemoteConfig
webdavSetup u c = do
@@ -201,14 +198,12 @@ withStoredFiles r k baseurl user pass onerr a
keyurl = davLocation baseurl k ++ keyFile k
davAction :: Remote -> a -> ((DavUrl, DavUser, DavPass) -> Annex a) -> Annex a
-davAction r unconfigured action = case config r of
- Nothing -> return unconfigured
- Just c -> do
- mcreds <- getCreds c (uuid r)
- case (mcreds, M.lookup "url" c) of
- (Just (user, pass), Just url) ->
- action (url, toDavUser user, toDavPass pass)
- _ -> return unconfigured
+davAction r unconfigured action = do
+ mcreds <- getCreds (config r) (uuid r)
+ case (mcreds, M.lookup "url" $ config r) of
+ (Just (user, pass), Just url) ->
+ action (url, toDavUser user, toDavPass pass)
+ _ -> return unconfigured
toDavUser :: String -> DavUser
toDavUser = B8.fromString