summaryrefslogtreecommitdiff
path: root/Command/RegisterUrl.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-05-22 22:41:36 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-05-22 22:41:36 -0400
commit280b59024768689feed03db4e7069e12f9605825 (patch)
tree2350b2747d669d44ebaafdb2b7fefe5b550b558b /Command/RegisterUrl.hs
parent0c2026f3d4109e810b050090b44bb406b6a11954 (diff)
fromkey, registerurl: Allow urls to be specified instead of keys, and generate URL keys.
This is especially useful because the caller doesn't need to generate valid url keys, which involves some escaping of characters, and may involve taking a md5sum of the url if it's too long.
Diffstat (limited to 'Command/RegisterUrl.hs')
-rw-r--r--Command/RegisterUrl.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/Command/RegisterUrl.hs b/Command/RegisterUrl.hs
index d0e806597..4282db58a 100644
--- a/Command/RegisterUrl.hs
+++ b/Command/RegisterUrl.hs
@@ -11,9 +11,9 @@ module Command.RegisterUrl where
import Common.Annex
import Command
-import Types.Key
import Logs.Web
import Annex.UUID
+import Command.FromKey (mkKey)
cmd :: [Command]
cmd = [notDirect $ notBareRepo $
@@ -25,7 +25,7 @@ seek = withWords start
start :: [String] -> CommandStart
start (keyname:url:[]) = do
- let key = fromMaybe (error "bad key") $ file2key keyname
+ let key = mkKey keyname
showStart "registerurl" url
next $ perform key url
start [] = do
@@ -38,7 +38,7 @@ massAdd = go True =<< map (separate (== ' ')) . lines <$> liftIO getContents
where
go status [] = next $ return status
go status ((keyname,u):rest) | not (null keyname) && not (null u) = do
- let key = fromMaybe (error $ "bad key " ++ keyname) $ file2key keyname
+ let key = mkKey keyname
ok <- perform' key u
let !status' = status && ok
go status' rest