webapp: Now automatically fills in any creds used by an existing remote when creating a new remote of the same type. Done for Internet Archive, S3, Glacier, and Box.com remotes.
This commit is contained in:
parent
8626e67e97
commit
c3498042fd
6 changed files with 122 additions and 50 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
{-# LANGUAGE ScopedTypeVariables, CPP #-}
|
||||
|
||||
module Remote.WebDAV (remote, davCreds, setCredsEnv) where
|
||||
module Remote.WebDAV (remote, davCreds, setCredsEnv, configUrl) where
|
||||
|
||||
import Network.Protocol.HTTP.DAV
|
||||
import qualified Data.Map as M
|
||||
|
@ -203,11 +203,14 @@ withStoredFiles r k baseurl user pass onerr a
|
|||
davAction :: Remote -> a -> ((DavUrl, DavUser, DavPass) -> Annex a) -> Annex a
|
||||
davAction r unconfigured action = do
|
||||
mcreds <- getCreds (config r) (uuid r)
|
||||
case (mcreds, M.lookup "url" $ config r) of
|
||||
case (mcreds, configUrl r) of
|
||||
(Just (user, pass), Just url) ->
|
||||
action (url, toDavUser user, toDavPass pass)
|
||||
_ -> return unconfigured
|
||||
|
||||
configUrl :: Remote -> Maybe DavUrl
|
||||
configUrl r = M.lookup "url" $ config r
|
||||
|
||||
toDavUser :: String -> DavUser
|
||||
toDavUser = B8.fromString
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue