mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-13 19:37:30 +01:00
Add migration code to put app data in proper spot on mac for fresh installs
This commit is contained in:
parent
cda49a1fe4
commit
ad7f9d78a1
4 changed files with 73 additions and 28 deletions
app-commons/src/main/scala/org/bitcoins/commons/config
core/src/main/scala/org/bitcoins/core/util
project
|
@ -2,11 +2,11 @@ package org.bitcoins.commons.config
|
|||
|
||||
import com.typesafe.config.{Config, ConfigFactory, ConfigParseOptions}
|
||||
import org.bitcoins.commons.util.BitcoinSLogger
|
||||
import org.bitcoins.core.config._
|
||||
import org.bitcoins.core.config.*
|
||||
import org.bitcoins.core.protocol.blockchain.BitcoinChainParams
|
||||
import org.bitcoins.core.util.StartStopAsync
|
||||
import org.bitcoins.core.util.{EnvUtil, StartStopAsync}
|
||||
|
||||
import java.nio.file._
|
||||
import java.nio.file.*
|
||||
import scala.concurrent.Future
|
||||
import scala.jdk.CollectionConverters.CollectionHasAsScala
|
||||
import scala.util.Properties
|
||||
|
@ -236,8 +236,37 @@ object AppConfig extends BitcoinSLogger {
|
|||
* TODO: use different directories on Windows and Mac, should probably mimic
|
||||
* what Bitcoin Core does
|
||||
*/
|
||||
private[bitcoins] lazy val DEFAULT_BITCOIN_S_DATADIR: Path =
|
||||
Paths.get(Properties.userHome, ".bitcoin-s")
|
||||
private[bitcoins] lazy val DEFAULT_BITCOIN_S_DATADIR: Path = {
|
||||
val base = Paths.get(Properties.userHome, ".bitcoin-s")
|
||||
if (EnvUtil.isLinux) {
|
||||
base
|
||||
} else if (EnvUtil.isMac) {
|
||||
// migration code to use proper location on mac
|
||||
val full = Paths
|
||||
.get(Properties.userHome)
|
||||
.resolve("Library")
|
||||
.resolve("Application Support")
|
||||
.resolve("bitcoin-s")
|
||||
if (Files.exists(full)) {
|
||||
full
|
||||
} else {
|
||||
if (Files.exists(base)) {
|
||||
// just use old directory for now
|
||||
// we will eventually migrate this in the future
|
||||
base
|
||||
} else {
|
||||
// fresh install, so use the proper spot
|
||||
full
|
||||
}
|
||||
}
|
||||
} else if (EnvUtil.isWindows) {
|
||||
// windows
|
||||
base
|
||||
} else {
|
||||
sys.error(s"Unsupported os=${EnvUtil.osName}")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private[bitcoins] lazy val DEFAULT_BITCOIN_S_CONF_FILE: String =
|
||||
"bitcoin-s.conf"
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.bitcoins.core.util
|
|||
import scala.util.Properties
|
||||
|
||||
object EnvUtil {
|
||||
private val osName = System.getProperty("os.name")
|
||||
lazy val osName: String = System.getProperty("os.name")
|
||||
|
||||
lazy val isLinux: Boolean = osName.startsWith("Linux")
|
||||
|
||||
|
|
|
@ -2,28 +2,15 @@
|
|||
import com.typesafe.sbt.SbtNativePackager.Docker
|
||||
import com.typesafe.sbt.SbtNativePackager.autoImport.packageName
|
||||
|
||||
import java.nio.file.Paths
|
||||
import com.typesafe.sbt.packager.Keys.{
|
||||
daemonUser,
|
||||
daemonUserUid,
|
||||
dockerAlias,
|
||||
dockerAliases,
|
||||
dockerCommands,
|
||||
dockerExposedVolumes,
|
||||
dockerRepository,
|
||||
dockerUpdateLatest,
|
||||
maintainer
|
||||
}
|
||||
import java.nio.file.{Files, Paths}
|
||||
import com.typesafe.sbt.packager.Keys.{daemonUser, daemonUserUid, dockerAlias, dockerAliases, dockerCommands, dockerExposedVolumes, dockerRepository, dockerUpdateLatest, maintainer}
|
||||
import com.typesafe.sbt.packager.archetypes.jlink.JlinkPlugin.autoImport.JlinkIgnore
|
||||
import com.typesafe.sbt.packager.docker.{Cmd, DockerChmodType}
|
||||
import com.typesafe.sbt.packager.docker.DockerPlugin.autoImport.{
|
||||
dockerAdditionalPermissions,
|
||||
dockerBaseImage
|
||||
}
|
||||
import sbt._
|
||||
import sbt.Keys._
|
||||
import com.typesafe.sbt.packager.docker.DockerPlugin.autoImport.{dockerAdditionalPermissions, dockerBaseImage}
|
||||
import sbt.*
|
||||
import sbt.Keys.*
|
||||
import sbtprotoc.ProtocPlugin.autoImport.PB
|
||||
import sbtassembly.AssemblyKeys._
|
||||
import sbtassembly.AssemblyKeys.*
|
||||
import sbtdynver.DynVer
|
||||
|
||||
import scala.sys.process.Process
|
||||
|
@ -243,8 +230,37 @@ object CommonSettings {
|
|||
)
|
||||
}
|
||||
|
||||
lazy val binariesPath =
|
||||
Paths.get(Properties.userHome, ".bitcoin-s", "binaries")
|
||||
lazy val binariesPath = {
|
||||
val base = Paths.get(Properties.userHome, ".bitcoin-s", "binaries")
|
||||
if (EnvUtil.isLinux) {
|
||||
base
|
||||
} else if (EnvUtil.isMac) {
|
||||
// migration code to use proper location on mac
|
||||
val full = Paths
|
||||
.get(Properties.userHome)
|
||||
.resolve("Library")
|
||||
.resolve("Application Support")
|
||||
.resolve("bitcoin-s")
|
||||
.resolve("binaries")
|
||||
if (Files.exists(full)) {
|
||||
full
|
||||
} else {
|
||||
if (Files.exists(base)) {
|
||||
// just use old directory for now
|
||||
// we will eventually migrate this in the future
|
||||
base
|
||||
} else {
|
||||
// fresh install, so use the proper spot
|
||||
full
|
||||
}
|
||||
}
|
||||
} else if (EnvUtil.isWindows) {
|
||||
// windows
|
||||
base
|
||||
} else {
|
||||
sys.error(s"Unsupported os=${EnvUtil.osName}")
|
||||
}
|
||||
}
|
||||
|
||||
lazy val cryptoJlinkIgnore = {
|
||||
Vector(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import scala.util.Properties
|
||||
|
||||
object EnvUtil {
|
||||
private val osName = System.getProperty("os.name")
|
||||
val osName = System.getProperty("os.name")
|
||||
|
||||
lazy val isLinux: Boolean = osName.startsWith("Linux")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue