summaryrefslogtreecommitdiff
path: root/Annex/Quvi.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-28 14:54:02 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-28 14:54:02 -0400
commitba81a7b4abcc4b14072bc8d717191151a50614c8 (patch)
tree6831e53dca9737115cc8ac4f1e72689f1e17e02c /Annex/Quvi.hs
parentb97207881a3336a4e8befe90e530954def022d93 (diff)
Probe for quvi version at run time.
Overhead: git annex addurl runs quvi --version once. And more bloat to Annex state..
Diffstat (limited to 'Annex/Quvi.hs')
-rw-r--r--Annex/Quvi.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/Annex/Quvi.hs b/Annex/Quvi.hs
index b0725bae7..1a2edf6b8 100644
--- a/Annex/Quvi.hs
+++ b/Annex/Quvi.hs
@@ -14,7 +14,20 @@ import qualified Annex
import Utility.Quvi
import Utility.Url
-withQuviOptions :: forall a. Query a -> [CommandParam] -> URLString -> Annex a
+withQuviOptions :: forall a. Query a -> [QuviParam] -> URLString -> Annex a
withQuviOptions a ps url = do
+ v <- quviVersion
opts <- map Param . annexQuviOptions <$> Annex.getGitConfig
- liftIO $ a (ps++opts) url
+ liftIO $ a v (map (\mkp -> mkp v) ps++opts) url
+
+quviSupported :: URLString -> Annex Bool
+quviSupported u = liftIO . flip supported u =<< quviVersion
+
+quviVersion :: Annex QuviVersion
+quviVersion = go =<< Annex.getState Annex.quviversion
+ where
+ go (Just v) = return v
+ go Nothing = do
+ v <- liftIO probeVersion
+ Annex.changeState $ \s -> s { Annex.quviversion = Just v }
+ return v