Skip to content

Commit

Permalink
small adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Jun 20, 2024
1 parent ad0f68d commit aa360aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.h2.mvstore.MVStoreException
import org.h2.tools.Upgrade

abstract class H2ConnectionProvider(
directory: () => AbsolutePath,
directory: => AbsolutePath,
name: String,
migrations: String,
) extends Cancelable {
Expand All @@ -33,7 +33,7 @@ abstract class H2ConnectionProvider(

protected def connection: Connection = connect()

protected def optDirectory: Option[AbsolutePath] = Try(directory()).toOption
protected def optDirectory: Option[AbsolutePath] = Try(directory).toOption
protected def databasePath: Option[AbsolutePath] =
optDirectory.map(_.resolve("metals.h2.db"))

Expand Down Expand Up @@ -92,9 +92,9 @@ abstract class H2ConnectionProvider(
val autoServer =
if (isAutoServer) ";AUTO_SERVER=TRUE"
else ""
val dbfile = directory().resolve("metals")
val dbfile = directory.resolve("metals")
// from "h2" % "2.0.206" the only option is the MVStore, which uses `metals.mv.db` file
val oldDbfile = directory().resolve("metals.h2.db")
val oldDbfile = directory.resolve("metals.h2.db")
if (oldDbfile.exists) {
scribe.info(s"Deleting old database format $oldDbfile")
oldDbfile.delete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import scala.meta.io.AbsolutePath

class SqlSharedIndices
extends H2ConnectionProvider(
() => AbsolutePath(Paths.get(sys.props("user.home"))).resolve(".metals"),
"metals-shared",
"/shared-db/migration",
directory =
AbsolutePath(Paths.get(sys.props("user.home"))).resolve(".metals"),
name = "metals-shared",
migrations = "/shared-db/migration",
) {

val jvmTypeHierarchy: JarTypeHierarchy = new JarTypeHierarchy(() => connect)
Expand Down
6 changes: 3 additions & 3 deletions metals/src/main/scala/scala/meta/internal/metals/Tables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ final class Tables(
workspace: AbsolutePath,
time: Time,
) extends H2ConnectionProvider(
() => workspace.resolve(".metals"),
"metals",
"/db/migration",
directory = workspace.resolve(".metals"),
name = "metals",
migrations = "/db/migration",
) {

val jarSymbols = new JarTopLevels(() => connection)
Expand Down

0 comments on commit aa360aa

Please sign in to comment.