Skip to content

Commit

Permalink
avoid using scala.reflect and use a safer way to delete rocksdb data
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurélien Richez committed Jun 7, 2021
1 parent caad67d commit 7401e36
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/scala/io/iohk/ethereum/Mantis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package io.iohk.ethereum
import io.iohk.ethereum.nodebuilder.{StdNode, TestNode}
import io.iohk.ethereum.utils.{Config, Logger}

import java.nio.file.{Files, Paths}
import java.util.logging.LogManager
import scala.reflect.io.Directory

object Mantis extends Logger {
def main(args: Array[String]): Unit = {
Expand All @@ -13,8 +13,7 @@ object Mantis extends Logger {
val node =
if (Config.testmode) {
log.info("Starting Mantis in test mode")
log.info("Deleting previous database {}", Config.Db.RocksDb.path)
Directory(Config.Db.RocksDb.path).deleteRecursively()
deleteRocksDBFiles()
new TestNode
} else new StdNode

Expand All @@ -23,4 +22,12 @@ object Mantis extends Logger {

node.start()
}

private def deleteRocksDBFiles(): Unit = {
log.info("Deleting previous database {}", Config.Db.RocksDb.path)
Files.list(Paths.get(Config.Db.RocksDb.path))
.map(_.toFile)
.filter(_.isFile)
.forEach(f => f.delete())
}
}

0 comments on commit 7401e36

Please sign in to comment.