diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-14 19:36:11 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-14 19:36:11 -0400 |
commit | b8ba60428a0b4c077482560757e830e9ba02a823 (patch) | |
tree | 68c247edd2570d9121c150b35838f114eb9f994e /BackendTypes.hs | |
parent | c4959fee47f168857998dea6d11395158251158d (diff) |
changed key to include backend name
Diffstat (limited to 'BackendTypes.hs')
-rw-r--r-- | BackendTypes.hs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/BackendTypes.hs b/BackendTypes.hs index e480f725b..e0f5f7373 100644 --- a/BackendTypes.hs +++ b/BackendTypes.hs @@ -5,7 +5,7 @@ module BackendTypes where -import Control.Monad.State +import Control.Monad.State (StateT) import Data.String.Utils import qualified GitRepo as Git @@ -19,12 +19,22 @@ data AnnexState = AnnexState { -- git-annex's monad type Annex = StateT AnnexState IO --- annexed filenames are mapped into keys -data Key = Key String deriving (Eq) +-- annexed filenames are mapped through a backend into keys +type KeyFrag = String +type BackendName = String +data Key = Key (BackendName, KeyFrag) deriving (Eq) --- show a key to convert it to a string +-- show a key to convert it to a string; the string includes the +-- name of the backend to avoid collisions between key strings instance Show Key where - show (Key v) = v + show (Key (b, k)) = b ++ ":" ++ k + +instance Read Key where + readsPrec _ s = [((Key (b,k)) ,"")] + where + l = split ":" s + b = l !! 0 + k = join ":" $ drop 1 l -- this structure represents a key/value backend data Backend = Backend { |