summaryrefslogtreecommitdiff
path: root/Types/Import.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2019-02-21 13:38:27 -0400
committerJoey Hess <joeyh@joeyh.name>2019-02-21 13:39:09 -0400
commitfd304dce60bfbfd962783c2f50ff3ec085af4746 (patch)
treea382846518262fce607a0e0ff70cbba591e50c4b /Types/Import.hs
parent936aee6a60e86b5caa35675f0a50a58c173b9bbb (diff)
split out Types.Import and some changes to the types in it
Diffstat (limited to 'Types/Import.hs')
-rw-r--r--Types/Import.hs43
1 files changed, 43 insertions, 0 deletions
diff --git a/Types/Import.hs b/Types/Import.hs
new file mode 100644
index 0000000000..d31780167d
--- /dev/null
+++ b/Types/Import.hs
@@ -0,0 +1,43 @@
+{- git-annex import types
+ -
+ - Copyright 2019 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Types.Import where
+
+import qualified Data.ByteString as S
+import Data.Char
+
+import Types.Export
+import Utility.QuickCheck
+import Utility.FileSystemEncoding
+
+{- Location of content on a remote that can be imported.
+ - This is just an alias to ExportLocation, because both are referring to a
+ - location on the remote. -}
+type ImportLocation = ExportLocation
+
+{- An identifier for content stored on a remote that has been imported into
+ - the repository. It should be reasonably short since it is stored in the
+ - git-annex branch. -}
+newtype ContentIdentifier = ContentIdentifier S.ByteString
+ deriving (Eq, Ord, Show)
+
+instance Arbitrary ContentIdentifier where
+ -- Avoid non-ascii ContentIdentifiers because fully arbitrary
+ -- strings may not be encoded using the filesystem
+ -- encoding, which is normally applied to all input.
+ arbitrary = ContentIdentifier . encodeBS
+ <$> arbitrary `suchThat` all isAscii
+
+{- List of files that can be imported from a remote. -}
+data ImportableContents = ImportableContents
+ { importableContents :: [(ImportLocation, ContentIdentifier)]
+ , importableHistory :: [ImportableContents]
+ -- ^ Used by remotes that support importing historical versions of
+ -- files that are stored in them. This is equivilant to a git
+ -- commit history.
+ }
+ deriving (Show)