diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-03-05 13:50:15 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-03-05 13:50:15 -0400 |
commit | f3958ecd07765975e4ea3d500cdc9694ad595d5e (patch) | |
tree | feac52e85c2809dbb85de05496c87ecd767adcc8 /Remote | |
parent | c80bd8d1c3993312dd36888d81bd80b48584fb2d (diff) |
Added SETURIPRESENT and SETURIMISSING to external special remote protocol
Useful for things like ipfs that don't use regular urls.
An external special remote can add a regular url to a key, and then
git-annex get will download it from the web. But for ipfs, we want to
instead tell git-annex that the uri uses OtherDownloader. Before this
change, the external special remote protocol lacked a way to do that.
Diffstat (limited to 'Remote')
-rw-r--r-- | Remote/External.hs | 7 | ||||
-rw-r--r-- | Remote/External/Types.hs | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Remote/External.hs b/Remote/External.hs index 0579400ed..7dd1736e4 100644 --- a/Remote/External.hs +++ b/Remote/External.hs @@ -223,6 +223,10 @@ handleRequest' lck external req mp responsehandler setUrlPresent (externalUUID external) key url handleRemoteRequest (SETURLMISSING key url) = setUrlMissing (externalUUID external) key url + handleRemoteRequest (SETURIPRESENT key uri) = + withurl (SETURLPRESENT key) uri + handleRemoteRequest (SETURIMISSING key uri) = + withurl (SETURLMISSING key) uri handleRemoteRequest (GETURLS key prefix) = do mapM_ (send . VALUE . fst . getDownloader) =<< getUrlsWithPrefix key prefix @@ -242,6 +246,9 @@ handleRequest' lck external req mp responsehandler } where base = replace "/" "_" $ fromUUID (externalUUID external) ++ "-" ++ setting + + withurl mk uri = handleRemoteRequest $ mk $ + setDownloader (show uri) OtherDownloader sendMessage :: Sendable m => ExternalLock -> External -> m -> Annex () sendMessage lck external m = diff --git a/Remote/External/Types.hs b/Remote/External/Types.hs index d0fb2ff7a..c7a28a359 100644 --- a/Remote/External/Types.hs +++ b/Remote/External/Types.hs @@ -43,6 +43,7 @@ import Utility.Url (URLString) import qualified Utility.SimpleProtocol as Proto import Control.Concurrent.STM +import Network.URI -- If the remote is not yet running, the ExternalState TMVar is empty. data External = External @@ -182,6 +183,8 @@ data RemoteRequest | GETSTATE Key | SETURLPRESENT Key URLString | SETURLMISSING Key URLString + | SETURIPRESENT Key URI + | SETURIMISSING Key URI | GETURLS Key String | DEBUG String deriving (Show) @@ -202,6 +205,8 @@ instance Proto.Receivable RemoteRequest where parseCommand "GETSTATE" = Proto.parse1 GETSTATE parseCommand "SETURLPRESENT" = Proto.parse2 SETURLPRESENT parseCommand "SETURLMISSING" = Proto.parse2 SETURLMISSING + parseCommand "SETURIPRESENT" = Proto.parse2 SETURIPRESENT + parseCommand "SETURIMISSING" = Proto.parse2 SETURIMISSING parseCommand "GETURLS" = Proto.parse2 GETURLS parseCommand "DEBUG" = Proto.parse1 DEBUG parseCommand _ = Proto.parseFail @@ -288,3 +293,7 @@ instance Proto.Serializable [(URLString, Size, FilePath)] where where go c (url:sz:f:rest) = go ((url, readish sz, f):c) rest go c _ = reverse c + +instance Proto.Serializable URI where + serialize = show + deserialize = parseURI |