mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 10:35:57 +03:00
Sync.{makeTempEntity,tempEntityType}
This commit is contained in:
parent
eab5010cf9
commit
e698acf0e8
@ -0,0 +1,22 @@
|
||||
module U.Codebase.Sqlite.TempEntityType where
|
||||
|
||||
import Database.SQLite.Simple (SQLData (SQLInteger))
|
||||
import Database.SQLite.Simple.FromField (FromField (..))
|
||||
import Database.SQLite.Simple.ToField (ToField (..))
|
||||
|
||||
-- | Don't reorder these, they are part of the database,
|
||||
-- and the ToField and FromField implementation currently
|
||||
-- depends on the derived Enum implementation.
|
||||
data TempEntityType
|
||||
= TermComponentType -- 0
|
||||
| DeclComponentType -- 1
|
||||
| NamespaceType -- 2
|
||||
| PatchType -- 3
|
||||
| CausalType -- 4
|
||||
deriving (Eq, Ord, Show, Enum)
|
||||
|
||||
instance ToField TempEntityType where
|
||||
toField = SQLInteger . fromIntegral . fromEnum
|
||||
|
||||
instance FromField TempEntityType where
|
||||
fromField = fmap toEnum . fromField
|
@ -43,6 +43,7 @@ library
|
||||
U.Codebase.Sqlite.Symbol
|
||||
U.Codebase.Sqlite.Sync22
|
||||
U.Codebase.Sqlite.TempEntity
|
||||
U.Codebase.Sqlite.TempEntityType
|
||||
U.Codebase.Sqlite.Term.Format
|
||||
other-modules:
|
||||
Paths_unison_codebase_sqlite
|
||||
|
@ -15,6 +15,7 @@ dependencies:
|
||||
- ListLike
|
||||
- async
|
||||
- base
|
||||
- bytes
|
||||
- bytestring
|
||||
- configurator
|
||||
- containers >= 0.6.3
|
||||
|
@ -11,6 +11,7 @@ where
|
||||
|
||||
import Control.Monad.Extra ((||^))
|
||||
import Control.Monad.Reader (ReaderT, runReaderT)
|
||||
import Data.Bytes.Put (runPutS)
|
||||
import qualified Data.List.NonEmpty as List.NonEmpty
|
||||
import qualified Data.Map.NonEmpty as NEMap
|
||||
import qualified Data.Set as Set
|
||||
@ -20,6 +21,10 @@ import U.Codebase.HashTags (CausalHash (unCausalHash))
|
||||
import U.Codebase.Sqlite.Connection (Connection)
|
||||
import U.Codebase.Sqlite.DbId (HashId)
|
||||
import qualified U.Codebase.Sqlite.Queries as Q
|
||||
import qualified U.Codebase.Sqlite.Serialization as S
|
||||
import U.Codebase.Sqlite.TempEntity (TempEntity)
|
||||
import qualified U.Codebase.Sqlite.TempEntity as TempEntity
|
||||
import qualified U.Codebase.Sqlite.TempEntityType as TempEntity
|
||||
import qualified U.Util.Base32Hex as Base32Hex
|
||||
import qualified U.Util.Hash as Hash
|
||||
import Unison.Prelude
|
||||
@ -214,12 +219,12 @@ download conn repoName = do
|
||||
let putInMainStorage :: Share.Hash -> Share.Entity Text Share.Hash Share.HashJWT -> IO ()
|
||||
putInMainStorage _hash _entity = undefined
|
||||
let putInTempStorage :: Share.Hash -> Share.Entity Text Share.Hash Share.HashJWT -> IO ()
|
||||
putInTempStorage _hash _entity = do
|
||||
let bytes = case _entity of
|
||||
_ -> undefined
|
||||
|
||||
putInTempStorage _hash entity = do
|
||||
-- convert the blob to the data type we have a serializer for
|
||||
let tempEntity = makeTempEntity entity
|
||||
_entityType = tempEntityType entity
|
||||
-- serialize the blob
|
||||
let _bytes = runPutS (S.putTempEntity tempEntity)
|
||||
-- insert the blob
|
||||
undefined
|
||||
let insertMissingDependencies = undefined
|
||||
@ -400,3 +405,19 @@ _downloadEntities = undefined
|
||||
|
||||
_uploadEntities :: Share.UploadEntitiesRequest -> IO UploadEntitiesResponse
|
||||
_uploadEntities = undefined
|
||||
|
||||
makeTempEntity :: Share.Entity Text Share.Hash Share.HashJWT -> TempEntity
|
||||
makeTempEntity e = case e of
|
||||
Share.TC _ -> (TempEntity.TC _)
|
||||
Share.DC _ -> (TempEntity.DC _)
|
||||
Share.P _ -> (TempEntity.P _)
|
||||
Share.N _ -> (TempEntity.N _)
|
||||
Share.C _ -> (TempEntity.C _)
|
||||
|
||||
tempEntityType :: Share.Entity Text Share.Hash Share.HashJWT -> TempEntity.TempEntityType
|
||||
tempEntityType = \case
|
||||
Share.TC tc -> TempEntity.TermComponentType
|
||||
Share.DC dc -> TempEntity.DeclComponentType
|
||||
Share.P pa -> TempEntity.PatchType
|
||||
Share.N name -> TempEntity.NamespaceType
|
||||
Share.C ca -> TempEntity.CausalType
|
||||
|
@ -97,6 +97,7 @@ library
|
||||
, aeson
|
||||
, async
|
||||
, base
|
||||
, bytes
|
||||
, bytestring
|
||||
, configurator
|
||||
, containers >=0.6.3
|
||||
@ -189,6 +190,7 @@ executable cli-integration-tests
|
||||
, aeson
|
||||
, async
|
||||
, base
|
||||
, bytes
|
||||
, bytestring
|
||||
, code-page
|
||||
, configurator
|
||||
@ -279,6 +281,7 @@ executable transcripts
|
||||
, aeson
|
||||
, async
|
||||
, base
|
||||
, bytes
|
||||
, bytestring
|
||||
, code-page
|
||||
, configurator
|
||||
@ -373,6 +376,7 @@ executable unison
|
||||
, aeson
|
||||
, async
|
||||
, base
|
||||
, bytes
|
||||
, bytestring
|
||||
, code-page
|
||||
, configurator
|
||||
@ -472,6 +476,7 @@ test-suite cli-tests
|
||||
, aeson
|
||||
, async
|
||||
, base
|
||||
, bytes
|
||||
, bytestring
|
||||
, code-page
|
||||
, configurator
|
||||
|
Loading…
Reference in New Issue
Block a user