Skip to content

Commit

Permalink
bugfix: Metals SqlSharedIndices.scala XDG path violation
Browse files Browse the repository at this point in the history
  • Loading branch information
untainsYD authored and tgodzik committed Sep 27, 2024
1 parent 8a1b1e0 commit 6557240
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@ package scala.meta.internal.metals

import java.nio.file.Paths

import scala.util.Properties

import scala.meta.io.AbsolutePath

object MetalsDirectories {
def getMetalsDirectory: AbsolutePath = {
if (Properties.isLinux) {
Option(System.getenv("XDG_DATA_HOME"))
.map(xdg => Paths.get(xdg, "metals"))
.getOrElse(Paths.get(sys.props("user.home"), ".local", "share", "metals"))
} else {
Paths.get(sys.props("user.home"), ".metals")
}
}.toAbsolutePath
}

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

0 comments on commit 6557240

Please sign in to comment.