diff options
author | Joey Hess <joeyh@joeyh.name> | 2014-12-11 12:47:57 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2014-12-11 12:47:57 -0400 |
commit | bc0bf97b20c48e1d1a35d25e2e76a311c102438c (patch) | |
tree | 05934001ff6b3060cb477a1bd017316827eb050b /Command/AddUrl.hs | |
parent | 7f5e752b41b559bce358a9d6a053a7b195706e80 (diff) |
let url claims optionally include a suggested filename
Diffstat (limited to 'Command/AddUrl.hs')
-rw-r--r-- | Command/AddUrl.hs | 15 |
1 files changed, 8 insertions, 7 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 |