mirror of https://github.com/voidlizard/hbs2
removing excess constraints
This commit is contained in:
parent
b91f0323e6
commit
227f29e8bb
|
@ -175,6 +175,9 @@ main = flip runContT pure do
|
||||||
|
|
||||||
void $ lift $ withGit3Env env do
|
void $ lift $ withGit3Env env do
|
||||||
|
|
||||||
|
-- d_ <- asks gitRuntimeDict
|
||||||
|
-- atomically $ writeTVar d_ (Just (RuntimeDict fuck))
|
||||||
|
|
||||||
conf <- readLocalConf
|
conf <- readLocalConf
|
||||||
|
|
||||||
cli <- parseCLI
|
cli <- parseCLI
|
||||||
|
|
|
@ -21,11 +21,12 @@ main = flip runContT pure do
|
||||||
cli <- parseTop (unlines $ unwords <$> splitForms argz)
|
cli <- parseTop (unlines $ unwords <$> splitForms argz)
|
||||||
& either (error.show) pure
|
& either (error.show) pure
|
||||||
|
|
||||||
env <- nullGit3Env
|
tvd <- newTVarIO theDict
|
||||||
|
env' <- nullGit3Env
|
||||||
|
let env = env' { gitRuntimeDict = Just (RuntimeDict tvd) }
|
||||||
|
|
||||||
void $ lift $ withGit3Env env do
|
void $ lift $ withGit3Env env do
|
||||||
conf <- readLocalConf
|
conf <- readLocalConf
|
||||||
let dict = theDict
|
recover $ setupLogger >> runEval tvd (conf <> cli)
|
||||||
recover $ setupLogger >> run dict (conf <> cli)
|
|
||||||
`finally` silence
|
`finally` silence
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,4 @@ import Control.Monad.Trans.Maybe
|
||||||
|
|
||||||
{- HLINT ignore "Functor law"-}
|
{- HLINT ignore "Functor law"-}
|
||||||
|
|
||||||
getConfigPath :: MonadIO m => m (Maybe FilePath)
|
|
||||||
getConfigPath = do
|
|
||||||
let name = ".hbs2-git3"
|
|
||||||
runMaybeT do
|
|
||||||
gitDir
|
|
||||||
>>= toMPlus <&> (</> name) . takeDirectory
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,9 @@ exportEntries prefix = do
|
||||||
let refs = HM.toList $ HM.fromList refs'
|
let refs = HM.toList $ HM.fromList refs'
|
||||||
export (Just h) refs
|
export (Just h) refs
|
||||||
|
|
||||||
export :: forall m . HBS2GitPerks m => Maybe GitHash -> [(GitRef, GitHash)] -> Git3 m ()
|
export :: forall m . ( Git3Perks m
|
||||||
|
)
|
||||||
|
=> Maybe GitHash -> [(GitRef, GitHash)] -> Git3 m ()
|
||||||
export mbh refs = withStateDo do
|
export mbh refs = withStateDo do
|
||||||
tn <- getNumCapabilities
|
tn <- getNumCapabilities
|
||||||
|
|
||||||
|
@ -169,18 +171,19 @@ export mbh refs = withStateDo do
|
||||||
|
|
||||||
when (exported > 0) do
|
when (exported > 0) do
|
||||||
href <- createTreeWithMetadata sto gk meta lbs >>= orThrowPassIO
|
href <- createTreeWithMetadata sto gk meta lbs >>= orThrowPassIO
|
||||||
writeLogEntry ("tree" <+> pretty ts <+> pretty href )
|
|
||||||
debug $ "SENDING" <+> pretty href <+> pretty fn
|
|
||||||
|
|
||||||
let payload = LBS.toStrict $ serialise (AnnotatedHashRef Nothing href)
|
let payload = LBS.toStrict $ serialise (AnnotatedHashRef Nothing href)
|
||||||
tx <- withGit3Env env $ genRefLogUpdate payload
|
|
||||||
|
|
||||||
let txh = hashObject @HbSync (serialise tx) & HashRef
|
withGit3Env env do
|
||||||
|
debug $ "SENDING" <+> pretty href <+> pretty fn
|
||||||
|
writeLogEntry ("tree" <+> pretty ts <+> pretty href )
|
||||||
|
tx <- genRefLogUpdate payload
|
||||||
|
|
||||||
atomically (modifyTVar txCheckQ (HS.insert txh))
|
let txh = hashObject @HbSync (serialise tx) & HashRef
|
||||||
|
|
||||||
callRpcWaitMay @RpcRefLogPost (TimeoutSec 2) reflogAPI tx
|
atomically (modifyTVar txCheckQ (HS.insert txh))
|
||||||
>>= orThrowUser "rpc timeout"
|
|
||||||
|
callRpcWaitMay @RpcRefLogPost (TimeoutSec 2) reflogAPI tx
|
||||||
|
>>= orThrowUser "rpc timeout"
|
||||||
|
|
||||||
rm fn
|
rm fn
|
||||||
next
|
next
|
||||||
|
|
|
@ -123,11 +123,6 @@ data ImportStage =
|
||||||
{- HLINT ignore "Functor law" -}
|
{- HLINT ignore "Functor law" -}
|
||||||
|
|
||||||
importGitRefLog :: forall m . ( HBS2GitPerks m
|
importGitRefLog :: forall m . ( HBS2GitPerks m
|
||||||
-- , HasStorage m
|
|
||||||
-- , HasClientAPI PeerAPI UNIX m
|
|
||||||
-- , HasClientAPI RefLogAPI UNIX m
|
|
||||||
-- , HasGitRemoteKey m
|
|
||||||
-- , MonadReader Git3Env m
|
|
||||||
)
|
)
|
||||||
=> Git3 m (Maybe HashRef)
|
=> Git3 m (Maybe HashRef)
|
||||||
|
|
||||||
|
@ -257,10 +252,10 @@ importGitRefLog = withStateDo $ ask >>= \case
|
||||||
Left e -> err (viaShow e) >> throwIO e
|
Left e -> err (viaShow e) >> throwIO e
|
||||||
|
|
||||||
|
|
||||||
groupKeysFile :: MonadIO m => Git3 m FilePath
|
groupKeysFile :: (MonadIO m) => Git3 m FilePath
|
||||||
groupKeysFile = getStatePathM <&> (</> "groupkeys")
|
groupKeysFile = getStatePathM <&> (</> "groupkeys")
|
||||||
|
|
||||||
readGroupKeyFile :: MonadIO m => Git3 m (Maybe HashRef)
|
readGroupKeyFile :: (MonadIO m) => Git3 m (Maybe HashRef)
|
||||||
readGroupKeyFile = do
|
readGroupKeyFile = do
|
||||||
file <- groupKeysFile
|
file <- groupKeysFile
|
||||||
debug $ "readGroupKeyFile" <+> pretty file
|
debug $ "readGroupKeyFile" <+> pretty file
|
||||||
|
|
|
@ -23,7 +23,7 @@ import HBS2.KeyMan.Keys.Direct
|
||||||
import HBS2.Data.Detect
|
import HBS2.Data.Detect
|
||||||
import HBS2.CLI.Run.MetaData (getTreeContents)
|
import HBS2.CLI.Run.MetaData (getTreeContents)
|
||||||
|
|
||||||
import Data.Config.Suckless
|
import Data.Config.Suckless.Script
|
||||||
|
|
||||||
import HBS2.Peer.RPC.API.Storage
|
import HBS2.Peer.RPC.API.Storage
|
||||||
import HBS2.Peer.RPC.Client.StorageClient
|
import HBS2.Peer.RPC.Client.StorageClient
|
||||||
|
@ -130,12 +130,14 @@ getRepoManifest = do
|
||||||
>>= orThrow GitRepoManifestMalformed
|
>>= orThrow GitRepoManifestMalformed
|
||||||
<&> RepoManifest
|
<&> RepoManifest
|
||||||
|
|
||||||
nullGit3Env :: MonadIO m => m Git3Env
|
nullGit3Env :: forall m . MonadIO m => m Git3Env
|
||||||
nullGit3Env = Git3Disconnected
|
nullGit3Env = Git3Disconnected
|
||||||
<$> newTVarIO defSegmentSize
|
<$> newTVarIO defSegmentSize
|
||||||
<*> newTVarIO defCompressionLevel
|
<*> newTVarIO defCompressionLevel
|
||||||
<*> newTVarIO defIndexBlockSize
|
<*> newTVarIO defIndexBlockSize
|
||||||
<*> newTVarIO Nothing
|
<*> newTVarIO Nothing
|
||||||
|
<*> pure Nothing
|
||||||
|
|
||||||
|
|
||||||
connectedDo :: (MonadIO m) => Git3 m a -> Git3 m a
|
connectedDo :: (MonadIO m) => Git3 m a -> Git3 m a
|
||||||
connectedDo what = do
|
connectedDo what = do
|
||||||
|
@ -153,7 +155,7 @@ withGit3Env env a = runReaderT (fromGit3 a) env
|
||||||
runGit3 :: Git3Perks m => Git3Env -> Git3 m b -> m b
|
runGit3 :: Git3Perks m => Git3Env -> Git3 m b -> m b
|
||||||
runGit3 env action = withGit3Env env action
|
runGit3 env action = withGit3Env env action
|
||||||
|
|
||||||
withStateDo :: MonadUnliftIO m => Git3 m a -> Git3 m a
|
withStateDo :: (MonadUnliftIO m) => Git3 m a -> Git3 m a
|
||||||
withStateDo action = do
|
withStateDo action = do
|
||||||
|
|
||||||
waitRepo Nothing =<< getGitRepoKeyThrow
|
waitRepo Nothing =<< getGitRepoKeyThrow
|
||||||
|
@ -169,6 +171,7 @@ recover m = fix \again -> do
|
||||||
soname <- detectRPC
|
soname <- detectRPC
|
||||||
`orDie` "can't locate hbs2-peer rpc"
|
`orDie` "can't locate hbs2-peer rpc"
|
||||||
|
|
||||||
|
|
||||||
flip runContT pure do
|
flip runContT pure do
|
||||||
|
|
||||||
client <- lift $ race (pause @'Seconds 1) (newMessagingUnix False 1.0 soname)
|
client <- lift $ race (pause @'Seconds 1) (newMessagingUnix False 1.0 soname)
|
||||||
|
@ -197,6 +200,8 @@ recover m = fix \again -> do
|
||||||
|
|
||||||
-- debug $ yellow $ "REPOKEY" <+> pretty (AsBase58 rk)
|
-- debug $ yellow $ "REPOKEY" <+> pretty (AsBase58 rk)
|
||||||
|
|
||||||
|
dict <- asks gitRuntimeDict
|
||||||
|
|
||||||
connected <- Git3Connected soname sto peer refLogAPI lwwAPI
|
connected <- Git3Connected soname sto peer refLogAPI lwwAPI
|
||||||
<$> newTVarIO rk
|
<$> newTVarIO rk
|
||||||
<*> newTVarIO Nothing
|
<*> newTVarIO Nothing
|
||||||
|
@ -204,6 +209,7 @@ recover m = fix \again -> do
|
||||||
<*> newTVarIO defSegmentSize
|
<*> newTVarIO defSegmentSize
|
||||||
<*> newTVarIO defCompressionLevel
|
<*> newTVarIO defCompressionLevel
|
||||||
<*> newTVarIO defIndexBlockSize
|
<*> newTVarIO defIndexBlockSize
|
||||||
|
<*> pure dict
|
||||||
|
|
||||||
|
|
||||||
liftIO $ withGit3Env connected do
|
liftIO $ withGit3Env connected do
|
||||||
|
|
|
@ -71,9 +71,7 @@ readLogFileLBS _ action = flip fix 0 \go n -> do
|
||||||
go (succ n)
|
go (succ n)
|
||||||
|
|
||||||
indexPath :: forall m . ( Git3Perks m
|
indexPath :: forall m . ( Git3Perks m
|
||||||
, MonadReader Git3Env m
|
) => Git3 m FilePath
|
||||||
, HasGitRemoteKey m
|
|
||||||
) => m FilePath
|
|
||||||
|
|
||||||
indexPath = getStatePathM
|
indexPath = getStatePathM
|
||||||
|
|
||||||
|
@ -127,7 +125,7 @@ mergeSortedFilesN getKey inputFiles outFile = do
|
||||||
mkState [] = Nothing
|
mkState [] = Nothing
|
||||||
mkState (x:xs) = Just (Entry (getKey x) (x:xs))
|
mkState (x:xs) = Just (Entry (getKey x) (x:xs))
|
||||||
|
|
||||||
compactIndex :: forall m . (Git3Perks m, HasGitRemoteKey m, MonadReader Git3Env m) => Natural -> m ()
|
compactIndex :: forall m . (Git3Perks m) => Natural -> Git3 m ()
|
||||||
compactIndex maxSize = do
|
compactIndex maxSize = do
|
||||||
idxPath <- getStatePathM
|
idxPath <- getStatePathM
|
||||||
mkdir idxPath
|
mkdir idxPath
|
||||||
|
@ -144,8 +142,8 @@ compactIndex maxSize = do
|
||||||
out <- liftIO $ emptyTempFile idxPath "objects-.idx"
|
out <- liftIO $ emptyTempFile idxPath "objects-.idx"
|
||||||
mergeSortedFilesN (BS.take 20) (map fst block) out
|
mergeSortedFilesN (BS.take 20) (map fst block) out
|
||||||
|
|
||||||
openIndex :: forall a m . (Git3Perks m, HasGitRemoteKey m, MonadReader Git3Env m)
|
openIndex :: forall a m . (Git3Perks m)
|
||||||
=> m (Index a)
|
=> Git3 m (Index a)
|
||||||
|
|
||||||
openIndex = do
|
openIndex = do
|
||||||
files <- listObjectIndexFiles
|
files <- listObjectIndexFiles
|
||||||
|
@ -211,9 +209,7 @@ indexFilterNewObjectsMem idx@Index{..} hashes = do
|
||||||
|
|
||||||
|
|
||||||
listObjectIndexFiles :: forall m . ( Git3Perks m
|
listObjectIndexFiles :: forall m . ( Git3Perks m
|
||||||
, MonadReader Git3Env m
|
) => Git3 m [(FilePath, Natural)]
|
||||||
, HasGitRemoteKey m
|
|
||||||
) => m [(FilePath, Natural)]
|
|
||||||
|
|
||||||
listObjectIndexFiles = do
|
listObjectIndexFiles = do
|
||||||
path <- indexPath
|
path <- indexPath
|
||||||
|
@ -275,13 +271,12 @@ bloomFilterSize n k p
|
||||||
|
|
||||||
|
|
||||||
updateReflogIndex :: forall m . ( Git3Perks m
|
updateReflogIndex :: forall m . ( Git3Perks m
|
||||||
, MonadReader Git3Env m
|
-- , HasClientAPI PeerAPI UNIX m
|
||||||
, HasClientAPI PeerAPI UNIX m
|
-- , HasClientAPI RefLogAPI UNIX m
|
||||||
, HasClientAPI RefLogAPI UNIX m
|
-- , HasStorage m
|
||||||
, HasStorage m
|
-- , HasGitRemoteKey m
|
||||||
, HasGitRemoteKey m
|
-- , HasIndexOptions m
|
||||||
, HasIndexOptions m
|
) => Git3 m ()
|
||||||
) => m ()
|
|
||||||
updateReflogIndex = do
|
updateReflogIndex = do
|
||||||
|
|
||||||
reflog <- getGitRemoteKey >>= orThrow Git3ReflogNotSet
|
reflog <- getGitRemoteKey >>= orThrow Git3ReflogNotSet
|
||||||
|
@ -398,11 +393,7 @@ updateReflogIndex = do
|
||||||
|
|
||||||
|
|
||||||
trimRefs :: forall m . ( Git3Perks m
|
trimRefs :: forall m . ( Git3Perks m
|
||||||
, MonadReader Git3Env m
|
) => Git3 m ()
|
||||||
, HasGitRemoteKey m
|
|
||||||
, HasStorage m
|
|
||||||
, HasClientAPI RefLogAPI UNIX m
|
|
||||||
) => m ()
|
|
||||||
trimRefs = do
|
trimRefs = do
|
||||||
idxPath <- indexPath
|
idxPath <- indexPath
|
||||||
files <- refsFiles
|
files <- refsFiles
|
||||||
|
@ -439,11 +430,7 @@ trimRefs = do
|
||||||
mapM_ rm files
|
mapM_ rm files
|
||||||
|
|
||||||
importedCheckpoint :: forall m . ( MonadIO m
|
importedCheckpoint :: forall m . ( MonadIO m
|
||||||
, MonadReader Git3Env m
|
) => Git3 m (Maybe HashRef)
|
||||||
, HasClientAPI RefLogAPI UNIX m
|
|
||||||
, HasStorage m
|
|
||||||
, HasGitRemoteKey m
|
|
||||||
) => m (Maybe HashRef)
|
|
||||||
|
|
||||||
importedCheckpoint = do
|
importedCheckpoint = do
|
||||||
state <- getStatePathM
|
state <- getStatePathM
|
||||||
|
@ -459,30 +446,22 @@ nullHash :: GitHash
|
||||||
nullHash = GitHash (BS.replicate 20 0)
|
nullHash = GitHash (BS.replicate 20 0)
|
||||||
|
|
||||||
txImported :: forall m . ( Git3Perks m
|
txImported :: forall m . ( Git3Perks m
|
||||||
, MonadReader Git3Env m
|
) => Git3 m (HashSet HashRef)
|
||||||
, HasClientAPI RefLogAPI UNIX m
|
|
||||||
, HasStorage m
|
|
||||||
, HasGitRemoteKey m
|
|
||||||
) => m (HashSet HashRef)
|
|
||||||
|
|
||||||
txImported = maybe mempty HS.fromList <$> runMaybeT do
|
txImported = maybe mempty HS.fromList <$> runMaybeT do
|
||||||
cp <- lift importedCheckpoint >>= toMPlus
|
cp <- lift importedCheckpoint >>= toMPlus
|
||||||
fmap fst <$> lift (txListAll (Just cp))
|
fmap fst <$> lift (txListAll (Just cp))
|
||||||
|
|
||||||
|
|
||||||
refsFiles :: forall m . (Git3Perks m, HasGitRemoteKey m) => m [FilePath]
|
refsFiles :: forall m . (Git3Perks m) => Git3 m [FilePath]
|
||||||
refsFiles = do
|
refsFiles = do
|
||||||
state <- getStatePathM
|
state <- getStatePathM
|
||||||
dirFiles state
|
dirFiles state
|
||||||
<&> filter ( (== ".ref") . takeExtension )
|
<&> filter ( (== ".ref") . takeExtension )
|
||||||
|
|
||||||
readRefsRaw :: forall m . ( Git3Perks m
|
readRefsRaw :: forall m . ( Git3Perks m
|
||||||
, MonadReader Git3Env m
|
|
||||||
, HasClientAPI RefLogAPI UNIX m
|
|
||||||
, HasStorage m
|
|
||||||
, HasGitRemoteKey m
|
|
||||||
)
|
)
|
||||||
=> [FilePath] -> m [Syntax C]
|
=> [FilePath] -> Git3 m [Syntax C]
|
||||||
|
|
||||||
readRefsRaw files = do
|
readRefsRaw files = do
|
||||||
mapM (liftIO . E.try @IOError . readFile) files
|
mapM (liftIO . E.try @IOError . readFile) files
|
||||||
|
@ -492,11 +471,7 @@ readRefsRaw files = do
|
||||||
|
|
||||||
{- HLINT ignore "Functor law"-}
|
{- HLINT ignore "Functor law"-}
|
||||||
importedRefs :: forall m . ( Git3Perks m
|
importedRefs :: forall m . ( Git3Perks m
|
||||||
, MonadReader Git3Env m
|
) => Git3 m [(GitRef, GitHash)]
|
||||||
, HasClientAPI RefLogAPI UNIX m
|
|
||||||
, HasStorage m
|
|
||||||
, HasGitRemoteKey m
|
|
||||||
) => m [(GitRef, GitHash)]
|
|
||||||
|
|
||||||
importedRefs = do
|
importedRefs = do
|
||||||
|
|
||||||
|
@ -521,11 +496,7 @@ importedRefs = do
|
||||||
pure rrefs
|
pure rrefs
|
||||||
|
|
||||||
updateImportedCheckpoint :: forall m . ( Git3Perks m
|
updateImportedCheckpoint :: forall m . ( Git3Perks m
|
||||||
, MonadReader Git3Env m
|
) => HashRef -> Git3 m ()
|
||||||
, HasClientAPI RefLogAPI UNIX m
|
|
||||||
, HasStorage m
|
|
||||||
, HasGitRemoteKey m
|
|
||||||
) => HashRef -> m ()
|
|
||||||
|
|
||||||
updateImportedCheckpoint cp = do
|
updateImportedCheckpoint cp = do
|
||||||
state <- getStatePathM
|
state <- getStatePathM
|
||||||
|
|
|
@ -7,6 +7,7 @@ module HBS2.Git3.State.Internal.Types
|
||||||
|
|
||||||
import HBS2.Git3.Prelude
|
import HBS2.Git3.Prelude
|
||||||
import HBS2.Git3.Config.Local
|
import HBS2.Git3.Config.Local
|
||||||
|
import HBS2.Git.Local.CLI
|
||||||
import HBS2.System.Dir
|
import HBS2.System.Dir
|
||||||
|
|
||||||
import Data.Config.Suckless.Script
|
import Data.Config.Suckless.Script
|
||||||
|
@ -21,23 +22,30 @@ import Control.Exception qualified as E
|
||||||
unit :: FilePath
|
unit :: FilePath
|
||||||
unit = "hbs2-git"
|
unit = "hbs2-git"
|
||||||
|
|
||||||
getStatePath :: (MonadIO m, Pretty ref) => ref -> m (Maybe FilePath)
|
getConfigPath :: MonadIO m => Git3 m (Maybe FilePath)
|
||||||
|
getConfigPath = do
|
||||||
|
let name = ".hbs2-git3"
|
||||||
|
runMaybeT do
|
||||||
|
gitDir
|
||||||
|
>>= toMPlus <&> (</> name) . takeDirectory
|
||||||
|
|
||||||
|
getStatePath :: (MonadIO m, Pretty ref) => ref -> Git3 m (Maybe FilePath)
|
||||||
getStatePath p = runMaybeT do
|
getStatePath p = runMaybeT do
|
||||||
d <- getConfigPath >>= toMPlus
|
d <- lift getConfigPath >>= toMPlus
|
||||||
pure $ d </> show (pretty p)
|
pure $ d </> show (pretty p)
|
||||||
|
|
||||||
getConfigRootFile :: MonadIO m => m FilePath
|
getConfigRootFile :: MonadIO m => Git3 m FilePath
|
||||||
getConfigRootFile = do
|
getConfigRootFile = do
|
||||||
getConfigPath
|
getConfigPath
|
||||||
>>= orThrow StateDirNotDefined
|
>>= orThrow StateDirNotDefined
|
||||||
<&> (</> "config")
|
<&> (</> "config")
|
||||||
|
|
||||||
readLocalConf :: MonadIO m => m [Syntax C]
|
readLocalConf :: forall m . HBS2GitPerks m => Git3 m [Syntax C]
|
||||||
readLocalConf = do
|
readLocalConf = do
|
||||||
|
|
||||||
fromMaybe mempty <$> runMaybeT do
|
fromMaybe mempty <$> runMaybeT do
|
||||||
|
|
||||||
conf <- liftIO (E.try @SomeException getConfigRootFile)
|
conf <- lift (try @_ @SomeException getConfigRootFile)
|
||||||
>>= toMPlus
|
>>= toMPlus
|
||||||
|
|
||||||
lift $ touch conf
|
lift $ touch conf
|
||||||
|
@ -93,12 +101,16 @@ instance Hashable GitWritePacksOptVal
|
||||||
instance GitWritePacksOpts (HashSet GitWritePacksOptVal) where
|
instance GitWritePacksOpts (HashSet GitWritePacksOptVal) where
|
||||||
excludeParents o = not $ HS.member WriteFullPack o
|
excludeParents o = not $ HS.member WriteFullPack o
|
||||||
|
|
||||||
|
data RuntimeDict = forall c m . (IsContext c, HBS2GitPerks m)
|
||||||
|
=> RuntimeDict { fromRuntimeDict :: TVar (Dict c m) }
|
||||||
|
|
||||||
data Git3Env =
|
data Git3Env =
|
||||||
Git3Disconnected
|
Git3Disconnected
|
||||||
{ gitPackedSegmentSize :: TVar Int
|
{ gitPackedSegmentSize :: TVar Int
|
||||||
, gitCompressionLevel :: TVar Int
|
, gitCompressionLevel :: TVar Int
|
||||||
, gitIndexBlockSize :: TVar Natural
|
, gitIndexBlockSize :: TVar Natural
|
||||||
, gitRepoKey :: TVar (Maybe GitRepoKey)
|
, gitRepoKey :: TVar (Maybe GitRepoKey)
|
||||||
|
, gitRuntimeDict :: Maybe RuntimeDict
|
||||||
}
|
}
|
||||||
| Git3Connected
|
| Git3Connected
|
||||||
{ peerSocket :: FilePath
|
{ peerSocket :: FilePath
|
||||||
|
@ -112,6 +124,7 @@ data Git3Env =
|
||||||
, gitPackedSegmentSize :: TVar Int
|
, gitPackedSegmentSize :: TVar Int
|
||||||
, gitCompressionLevel :: TVar Int
|
, gitCompressionLevel :: TVar Int
|
||||||
, gitIndexBlockSize :: TVar Natural
|
, gitIndexBlockSize :: TVar Natural
|
||||||
|
, gitRuntimeDict :: Maybe RuntimeDict
|
||||||
}
|
}
|
||||||
|
|
||||||
class HasExportOpts m where
|
class HasExportOpts m where
|
||||||
|
@ -169,6 +182,10 @@ instance (MonadIO m) => HasGitRemoteKey (Git3 m) where
|
||||||
e <- ask
|
e <- ask
|
||||||
liftIO $ atomically $ writeTVar (gitRepoKey e) (Just k)
|
liftIO $ atomically $ writeTVar (gitRepoKey e) (Just k)
|
||||||
|
|
||||||
|
class IsContext c => HasRuntimeDict c m where
|
||||||
|
getRuntimeDict :: m (TVar (Dict c m))
|
||||||
|
|
||||||
|
|
||||||
getGitRepoKeyThrow :: (MonadIO m, HasGitRemoteKey m) => m GitRepoKey
|
getGitRepoKeyThrow :: (MonadIO m, HasGitRemoteKey m) => m GitRepoKey
|
||||||
getGitRepoKeyThrow = getGitRepoKey >>= orThrow GitRepoRefNotSet
|
getGitRepoKeyThrow = getGitRepoKey >>= orThrow GitRepoRefNotSet
|
||||||
|
|
||||||
|
@ -216,7 +233,7 @@ instance HasClientAPI api UNIX (Git3 m) => HasClientAPI api UNIX (ContT whatever
|
||||||
instance HasClientAPI api UNIX (Git3 m) => HasClientAPI api UNIX (MaybeT (Git3 m)) where
|
instance HasClientAPI api UNIX (Git3 m) => HasClientAPI api UNIX (MaybeT (Git3 m)) where
|
||||||
getClientAPI = lift getClientAPI
|
getClientAPI = lift getClientAPI
|
||||||
|
|
||||||
getStatePathM :: forall m . (MonadIO m, HasGitRemoteKey m) => m FilePath
|
getStatePathM :: forall m . (MonadIO m) => Git3 m FilePath
|
||||||
getStatePathM = do
|
getStatePathM = do
|
||||||
k <- getGitRemoteKey >>= orThrow RefLogNotSet
|
k <- getGitRemoteKey >>= orThrow RefLogNotSet
|
||||||
getStatePath (AsBase58 k) >>= orThrow StateDirNotDefined
|
getStatePath (AsBase58 k) >>= orThrow StateDirNotDefined
|
||||||
|
|
Loading…
Reference in New Issue