2017-09-18 17:57:25 +00:00
|
|
|
{- git-annex exports
|
|
|
|
-
|
|
|
|
- Copyright 2017 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Annex.Export where
|
|
|
|
|
|
|
|
import Annex
|
|
|
|
import Annex.CatFile
|
|
|
|
import Types.Key
|
2017-09-19 18:20:47 +00:00
|
|
|
import Types.Remote
|
2017-09-18 17:57:25 +00:00
|
|
|
import qualified Git
|
|
|
|
|
2017-09-19 18:20:47 +00:00
|
|
|
import qualified Data.Map as M
|
2017-09-25 13:49:33 +00:00
|
|
|
import Control.Applicative
|
|
|
|
import Prelude
|
2017-09-19 18:20:47 +00:00
|
|
|
|
2017-09-18 17:57:25 +00:00
|
|
|
-- An export includes both annexed files and files stored in git.
|
|
|
|
-- For the latter, a SHA1 key is synthesized.
|
|
|
|
data ExportKey = AnnexKey Key | GitKey Key
|
|
|
|
deriving (Show, Eq, Ord)
|
|
|
|
|
|
|
|
asKey :: ExportKey -> Key
|
|
|
|
asKey (AnnexKey k) = k
|
|
|
|
asKey (GitKey k) = k
|
|
|
|
|
|
|
|
exportKey :: Git.Sha -> Annex ExportKey
|
|
|
|
exportKey sha = mk <$> catKey sha
|
|
|
|
where
|
|
|
|
mk (Just k) = AnnexKey k
|
|
|
|
mk Nothing = GitKey $ Key
|
|
|
|
{ keyName = show sha
|
|
|
|
, keyVariety = SHA1Key (HasExt False)
|
|
|
|
, keySize = Nothing
|
|
|
|
, keyMtime = Nothing
|
|
|
|
, keyChunkSize = Nothing
|
|
|
|
, keyChunkNum = Nothing
|
|
|
|
}
|
2017-09-19 18:20:47 +00:00
|
|
|
|
|
|
|
exportTree :: RemoteConfig -> Bool
|
|
|
|
exportTree c = case M.lookup "exporttree" c of
|
|
|
|
Just "yes" -> True
|
|
|
|
_ -> False
|