summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2014-12-11 12:47:57 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2014-12-11 12:47:57 -0400
commitbc0bf97b20c48e1d1a35d25e2e76a311c102438c (patch)
tree05934001ff6b3060cb477a1bd017316827eb050b /Command
parent7f5e752b41b559bce358a9d6a053a7b195706e80 (diff)
let url claims optionally include a suggested filename
Diffstat (limited to 'Command')
-rw-r--r--Command/AddUrl.hs15
-rw-r--r--Command/ReKey.hs3
-rw-r--r--Command/RmUrl.hs3
-rw-r--r--Command/Whereis.hs3
4 files changed, 14 insertions, 10 deletions
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index 76095d6e4..27c8359b0 100644
--- a/Command/AddUrl.hs
+++ b/Command/AddUrl.hs
@@ -21,6 +21,7 @@ import qualified Annex.Url as Url
import qualified Backend.URL
import qualified Remote
import qualified Types.Remote as Remote
+import Annex.URLClaim
import Annex.Content
import Logs.Web
import Types.Key
@@ -58,23 +59,23 @@ seek ps = do
start :: Bool -> Maybe FilePath -> Maybe Int -> String -> CommandStart
start relaxed optfile pathdepth s = do
- r <- Remote.claimingUrl s
+ (r, claim) <- urlClaim s
if Remote.uuid r == webUUID
then startWeb relaxed optfile pathdepth s
- else startRemote r relaxed optfile pathdepth s
+ else startRemote r claim relaxed optfile pathdepth s
-startRemote :: Remote -> Bool -> Maybe FilePath -> Maybe Int -> String -> CommandStart
-startRemote r relaxed optfile pathdepth s = do
+startRemote :: Remote -> URLClaim -> Bool -> Maybe FilePath -> Maybe Int -> String -> CommandStart
+startRemote r claim relaxed optfile pathdepth s = do
url <- case Url.parseURIRelaxed s of
Nothing -> error $ "bad uri " ++ s
Just u -> pure u
pathmax <- liftIO $ fileNameLengthLimit "."
- let file = choosefile $ url2file url pathdepth pathmax
+ let file = flip fromMaybe optfile $ case claim of
+ URLClaimedAs f -> f
+ URLClaimed -> url2file url pathdepth pathmax
showStart "addurl" file
showNote $ "using " ++ Remote.name r
next $ performRemote r relaxed s file
- where
- choosefile = flip fromMaybe optfile
performRemote :: Remote -> Bool -> URLString -> FilePath -> CommandPerform
performRemote r relaxed uri file = ifAnnexed file adduri geturi
diff --git a/Command/ReKey.hs b/Command/ReKey.hs
index 5dadf4e60..a0348d858 100644
--- a/Command/ReKey.hs
+++ b/Command/ReKey.hs
@@ -16,6 +16,7 @@ import qualified Command.Add
import Logs.Web
import Logs.Location
import Utility.CopyFile
+import Annex.URLClaim
import qualified Remote
cmd :: [Command]
@@ -63,7 +64,7 @@ cleanup file oldkey newkey = do
-- the new key as well.
urls <- getUrls oldkey
forM_ urls $ \url -> do
- r <- Remote.claimingUrl url
+ r <- fst <$> urlClaim url
setUrlPresent (Remote.uuid r) newkey url
-- Update symlink to use the new key.
diff --git a/Command/RmUrl.hs b/Command/RmUrl.hs
index 570004266..737c935c5 100644
--- a/Command/RmUrl.hs
+++ b/Command/RmUrl.hs
@@ -10,6 +10,7 @@ module Command.RmUrl where
import Common.Annex
import Command
import Logs.Web
+import Annex.URLClaim
import qualified Remote
cmd :: [Command]
@@ -27,7 +28,7 @@ start (file, url) = flip whenAnnexed file $ \_ key -> do
cleanup :: String -> Key -> CommandCleanup
cleanup url key = do
- r <- Remote.claimingUrl url
+ r <- fst <$> urlClaim url
let url' = if Remote.uuid r == webUUID
then url
else setDownloader url OtherDownloader
diff --git a/Command/Whereis.hs b/Command/Whereis.hs
index 314c204be..5f75badde 100644
--- a/Command/Whereis.hs
+++ b/Command/Whereis.hs
@@ -14,6 +14,7 @@ import Command
import Remote
import Logs.Trust
import Logs.Web
+import Annex.URLClaim
cmd :: [Command]
cmd = [noCommit $ withOptions (jsonOption : keyOptions) $
@@ -71,4 +72,4 @@ performRemote key remote = do
. filter (\(_, d) -> d == OtherDownloader)
. map getDownloader
<$> getUrls key
- filterM (\u -> (==) <$> pure remote <*> claimingUrl u) us
+ filterM (\u -> (==) <$> pure remote <*> (fst <$> urlClaim u)) us