webdav: Made exporttree remotes faster by caching connection to the server

Followed example of Remote.S3.
This commit is contained in:
Joey Hess 2020-03-20 12:48:43 -04:00
parent 24255b3c96
commit 4b92bbe8d7
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 108 additions and 80 deletions

View file

@ -15,7 +15,7 @@ import Creds
import qualified Remote.WebDAV as WebDAV
import Assistant.WebApp.MakeRemote
import qualified Remote
import Types.Remote (RemoteConfig)
import Types.Remote (RemoteConfig, config)
import Types.StandardGroups
import Logs.Remote
import Git.Types (RemoteName)
@ -89,16 +89,16 @@ postEnableWebDAVR _ = giveup "WebDAV not supported by this build"
#ifdef WITH_WEBDAV
makeWebDavRemote :: SpecialRemoteMaker -> RemoteName -> CredPair -> RemoteConfig -> Handler ()
makeWebDavRemote maker name creds config =
makeWebDavRemote maker name creds c =
setupCloudRemote TransferGroup Nothing $
maker name WebDAV.remote (Just creds) config
maker name WebDAV.remote (Just creds) c
{- Only returns creds previously used for the same hostname. -}
previouslyUsedWebDAVCreds :: String -> Annex (Maybe CredPair)
previouslyUsedWebDAVCreds hostname =
previouslyUsedCredPair WebDAV.davCreds WebDAV.remote samehost
where
samehost url = case urlHost =<< WebDAV.configUrl url of
samehost r = case urlHost =<< WebDAV.configUrl (config r) of
Nothing -> False
Just h -> h == hostname
#endif