summaryrefslogtreecommitdiff
path: root/Database/Types.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-09-18 13:57:25 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-09-18 13:59:59 -0400
commita5e968bb8d4c608c33463160ea2b583a3e34b8fc (patch)
treeffd59e071fadf718ed4f270d2cf2b67fda9b6315 /Database/Types.hs
parent9d2ac4d87dc98bd2ab60da38a7e98f0964fd1595 (diff)
add ExportTree table to export db
New table needed to look up what filenames are used in the currently exported tree, for reasons explained in export.mdwn. Also, added smart constructors for ExportLocation and ExportDirectory to make sure they contain filepaths with the right direction slashes. And some code refactoring. This commit was sponsored by Francois Marier on Patreon.
Diffstat (limited to 'Database/Types.hs')
-rw-r--r--Database/Types.hs21
1 files changed, 20 insertions, 1 deletions
diff --git a/Database/Types.hs b/Database/Types.hs
index a4b5fbcb1..49a63f067 100644
--- a/Database/Types.hs
+++ b/Database/Types.hs
@@ -1,6 +1,6 @@
{- types for SQL databases
-
- - Copyright 2015-2016 Joey Hess <id@joeyh.name>
+ - Copyright 2015-2017 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -16,6 +16,7 @@ import Data.Char
import Utility.PartialPrelude
import Key
import Utility.InodeCache
+import Git.Types (Ref(..))
-- A serialized Key
newtype SKey = SKey String
@@ -93,3 +94,21 @@ fromSFilePath (SFilePath s) = s
derivePersistField "SFilePath"
+-- A serialized Ref
+newtype SRef = SRef Ref
+
+-- Note that Read instance does not work when used in any kind of complex
+-- data structure.
+instance Read SRef where
+ readsPrec _ s = [(SRef (Ref s), "")]
+
+instance Show SRef where
+ show (SRef (Ref s)) = s
+
+derivePersistField "SRef"
+
+toSRef :: Ref -> SRef
+toSRef = SRef
+
+fromSRef :: SRef -> Ref
+fromSRef (SRef r) = r