@@ -12,6 +12,7 @@ import Cardano.Node.Types
1212import Cardano.Tools.DBSynthesizer.Forging
1313import Cardano.Tools.DBSynthesizer.Orphans ()
1414import Cardano.Tools.DBSynthesizer.Types
15+ import Control.Monad (filterM )
1516import Control.Monad.Trans.Except (ExceptT )
1617import Control.Monad.Trans.Except.Extra (firstExceptT ,
1718 handleIOExceptT , hoistEither , runExceptT )
@@ -20,6 +21,7 @@ import Data.Aeson as Aeson (FromJSON, Result (..), Value,
2021 eitherDecodeFileStrict' , eitherDecodeStrict' , fromJSON )
2122import Data.Bool (bool )
2223import Data.ByteString as BS (ByteString , readFile )
24+ import qualified Data.Set as Set
2325import Ouroboros.Consensus.Cardano.Block
2426import Ouroboros.Consensus.Cardano.Node
2527import Ouroboros.Consensus.Config (TopLevelConfig , configStorage )
@@ -170,11 +172,12 @@ preOpenChainDB :: DBSynthesizerOpenMode -> FilePath -> IO ()
170172preOpenChainDB mode db =
171173 doesDirectoryExist db >>= bool create checkMode
172174 where
173- checkIsDB ls = length ls <= 3 && all (`elem` [" immutable" , " ledger" , " volatile" ]) ls
175+ checkIsDB ls = Set. fromList ls `Set.isSubsetOf` chainDBDirs
176+ chainDBDirs = Set. fromList [" immutable" , " ledger" , " volatile" , " gsm" ]
174177 loc = " preOpenChainDB: '" ++ db ++ " '"
175178 create = createDirectoryIfMissing True db
176179 checkMode = do
177- isChainDB <- checkIsDB <$> listDirectory db
180+ isChainDB <- checkIsDB <$> listSubdirectories db
178181 case mode of
179182 OpenCreate ->
180183 fail $ loc ++ " already exists. Use -f to overwrite or -a to append."
@@ -184,5 +187,9 @@ preOpenChainDB mode db =
184187 removePathForcibly db >> create
185188 _ ->
186189 fail $ loc ++ " is non-empty and does not look like a ChainDB"
187- <> " (i.e. its entries are not exactly 'immutable'/'ledger'/'volatile')."
188- <> " Aborting."
190+ <> " (i.e. it contains directories other than"
191+ <> " 'immutable'/'ledger'/'volatile'/'gsm'). Aborting."
192+
193+ listSubdirectories path = filterM isDir =<< listDirectory path
194+ where
195+ isDir p = doesDirectoryExist (path </> p)
0 commit comments