summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Logs/Web.hs4
-rw-r--r--Remote/External.hs6
-rw-r--r--Remote/External/Types.hs6
-rw-r--r--debian/changelog2
-rw-r--r--doc/design/external_special_remote_protocol.mdwn13
-rw-r--r--doc/todo/extensible_addurl.mdwn2
6 files changed, 30 insertions, 3 deletions
diff --git a/Logs/Web.hs b/Logs/Web.hs
index 1d16e10b3..f31215a4f 100644
--- a/Logs/Web.hs
+++ b/Logs/Web.hs
@@ -9,6 +9,7 @@ module Logs.Web (
URLString,
webUUID,
getUrls,
+ getUrlsWithPrefix,
setUrlPresent,
setUrlMissing,
knownUrls,
@@ -46,6 +47,9 @@ getUrls key = go $ urlLogFile key : oldurlLogs key
then go ls
else return us
+getUrlsWithPrefix :: Key -> String -> Annex [URLString]
+getUrlsWithPrefix key prefix = filter (prefix `isPrefixOf`) <$> getUrls key
+
setUrlPresent :: Key -> URLString -> Annex ()
setUrlPresent key url = do
us <- getUrls key
diff --git a/Remote/External.hs b/Remote/External.hs
index e907ab0cf..dca273d23 100644
--- a/Remote/External.hs
+++ b/Remote/External.hs
@@ -19,6 +19,7 @@ import Utility.Metered
import Logs.Transfer
import Logs.PreferredContent.Raw
import Logs.RemoteState
+import Logs.Web
import Config.Cost
import Annex.UUID
import Creds
@@ -215,6 +216,11 @@ handleRequest' lck external req mp responsehandler
state <- fromMaybe ""
<$> getRemoteState (externalUUID external) key
send $ VALUE state
+ handleRemoteRequest (SETURLPRESENT key url) = setUrlPresent key url
+ handleRemoteRequest (SETURLMISSING key url) = setUrlMissing key url
+ handleRemoteRequest (GETURLS key prefix) = do
+ mapM_ (send . VALUE) =<< getUrlsWithPrefix key prefix
+ send (VALUE "") -- end of list
handleRemoteRequest (DEBUG msg) = liftIO $ debugM "external" msg
handleRemoteRequest (VERSION _) =
sendMessage lck external $ ERROR "too late to send VERSION"
diff --git a/Remote/External/Types.hs b/Remote/External/Types.hs
index 3a69ae9ea..cdcb657ea 100644
--- a/Remote/External/Types.hs
+++ b/Remote/External/Types.hs
@@ -165,6 +165,9 @@ data RemoteRequest
| GETWANTED
| SETSTATE Key String
| GETSTATE Key
+ | SETURLPRESENT Key String
+ | SETURLMISSING Key String
+ | GETURLS Key String
| DEBUG String
deriving (Show)
@@ -182,6 +185,9 @@ instance Proto.Receivable RemoteRequest where
parseCommand "GETWANTED" = Proto.parse0 GETWANTED
parseCommand "SETSTATE" = Proto.parse2 SETSTATE
parseCommand "GETSTATE" = Proto.parse1 GETSTATE
+ parseCommand "SETURLPRESENT" = Proto.parse2 SETURLPRESENT
+ parseCommand "SETURLMISSING" = Proto.parse2 SETURLMISSING
+ parseCommand "GETURLS" = Proto.parse2 GETURLS
parseCommand "DEBUG" = Proto.parse1 DEBUG
parseCommand _ = Proto.parseFail
diff --git a/debian/changelog b/debian/changelog
index 0a28d9a12..270d3187f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ git-annex (5.20141204) UNRELEASED; urgency=medium
* Webapp: When adding a new box.com remote, use the new style chunking.
Thanks, Jon Ander PeƱalba.
+ * External special remote protocol now includes commands for setting
+ and getting the urls associated with a key.
-- Joey Hess <id@joeyh.name> Fri, 05 Dec 2014 13:42:08 -0400
diff --git a/doc/design/external_special_remote_protocol.mdwn b/doc/design/external_special_remote_protocol.mdwn
index 4219f1193..00533095c 100644
--- a/doc/design/external_special_remote_protocol.mdwn
+++ b/doc/design/external_special_remote_protocol.mdwn
@@ -247,6 +247,17 @@ in control.
* `GETSTATE Key`
Gets any state that has been stored for the key.
(git-annex replies with VALUE followed by the state.)
+* `SETURLPRESENT Key Value`
+ Records an url (or uri) where the Key can be downloaded from.
+* `SETURLMISSING Key Value`
+ Records that the key can no longer be downloaded from the specified
+ url (or uri).
+* `GETURLS Key Value`
+ Gets the recorded urls where a Key can be downloaded from.
+ Only urls that start with the Value will be returned. The Value
+ may be empty to get all urls.
+ (git-annex replies one or more times with VALUE for each url.
+ The final VALUE has an empty value, indicating the end of the url list.)
* `DEBUG message`
Tells git-annex to display the message if --debug is enabled.
@@ -288,7 +299,5 @@ start a new process the next time it needs to use a remote.
the remote. However, \n and probably \0 need to be escaped somehow in the
file data, which adds complication.
* uuid discovery during INITREMOTE.
-* Support for getting and setting the list of urls that can be associated
- with a key.
* Hook into webapp. Needs a way to provide some kind of prompt to the user
in the webapp, etc.
diff --git a/doc/todo/extensible_addurl.mdwn b/doc/todo/extensible_addurl.mdwn
index b040c11c4..63b03e402 100644
--- a/doc/todo/extensible_addurl.mdwn
+++ b/doc/todo/extensible_addurl.mdwn
@@ -36,7 +36,7 @@ and so know where to download from. (Much as the web special remote already
does.)
Prerequisite: Expand the external special remote interface to support
-accessing the url log.
+accessing the url log. (done)
----