diff options
author | Joey Hess <joeyh@joeyh.name> | 2014-12-11 15:32:42 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2014-12-11 15:33:42 -0400 |
commit | c4ff79b1a460a3526c6772ab754cb34e5f7f3dd2 (patch) | |
tree | 80bea71f1d453348cb2d0a92ce10e463aab9259e /Types | |
parent | 4e88f7e9af6a776347649047f2473e470a729ed9 (diff) |
Expand checkurl to support recommended filename, and multi-file-urls
This commit was sponsored by an anonymous bitcoiner.
Diffstat (limited to 'Types')
-rw-r--r-- | Types/Remote.hs | 8 | ||||
-rw-r--r-- | Types/UrlContents.hs | 19 |
2 files changed, 23 insertions, 4 deletions
diff --git a/Types/Remote.hs b/Types/Remote.hs index baa857906..4d17abf95 100644 --- a/Types/Remote.hs +++ b/Types/Remote.hs @@ -25,6 +25,7 @@ import Types.UUID import Types.GitConfig import Types.Availability import Types.Creds +import Types.UrlContents import Config.Cost import Utility.Metered import Git.Types @@ -104,11 +105,10 @@ data RemoteA a = Remote { getInfo :: a [(String, String)], -- Some remotes can download from an url (or uri). claimUrl :: Maybe (URLString -> a Bool), - -- Checks that the url is accessible, and gets the size of its - -- content. Returns Nothing if the url is accessible, but - -- its size cannot be determined inexpensively. + -- Checks that the url is accessible, and gets information about + -- its contents, without downloading the full content. -- Throws an exception if the url is inaccessible. - checkUrl :: URLString -> a (Maybe Integer) + checkUrl :: Maybe (URLString -> a UrlContents) } instance Show (RemoteA a) where diff --git a/Types/UrlContents.hs b/Types/UrlContents.hs new file mode 100644 index 000000000..81b195fe3 --- /dev/null +++ b/Types/UrlContents.hs @@ -0,0 +1,19 @@ +{- git-annex URL contents + - + - Copyright 2014 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Types.UrlContents where + +import Utility.Url + +data UrlContents + -- An URL contains a file, whose size may be known. + -- A default filename will be provided, and can be overridded + -- or built on. + = UrlContents (Maybe Integer) (FilePath -> FilePath) + -- Sometimes an URL points to multiple files, each accessible + -- by their own URL. + | UrlNested [(URLString, UrlContents)] |