Skip to content

Commit

Permalink
Use config filename as hint for target directory. (#205)
Browse files Browse the repository at this point in the history
Bitcoin differs from all other daemons where the daemon name does not
match the configuration and target directory name. Instead of relying on
the daemon name use the configuration name instead to determine what the
target directory is. This change was made over all 3 components that are
being installed.
  • Loading branch information
marcopeereboom authored Nov 23, 2020
1 parent b30afe0 commit 1a550ba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
6 changes: 4 additions & 2 deletions cmd/dcrinstall/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ func preconditionsBitcoinInstall() error {

expectedConfigFiles++

name := bitcoinf[k].Name
ext := filepath.Ext(bitcoinf[k].Config)
name := strings.TrimSuffix(bitcoinf[k].Config, ext)
dir := dcrutil.AppDataDir(name, true)
filename := filepath.Join(dir, bitcoinf[k].Config)
if exists(filename) {
Expand Down Expand Up @@ -334,7 +335,8 @@ func installBitcoinBundleConfig() error {
}

// Check if the config file is already installed.
name := bitcoinf[k].Name
ext := filepath.Ext(bitcoinf[k].Config)
name := strings.TrimSuffix(bitcoinf[k].Config, ext)
dir := dcrutil.AppDataDir(name, true)
dst := filepath.Join(dir, bitcoinf[k].Config)
if exists(dst) {
Expand Down
8 changes: 6 additions & 2 deletions cmd/dcrinstall/dcrdex.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ func preconditionsDcrdexInstall() error {

expectedConfigFiles++

dir := dcrutil.AppDataDir(dexf[k].Name, false)
ext := filepath.Ext(dexf[k].Config)
name := strings.TrimSuffix(dexf[k].Config, ext)
dir := dcrutil.AppDataDir(name, false)
filename := filepath.Join(dir, dexf[k].Config)
if exists(filename) {
log.Printf("Config %s -- already installed", filename)
Expand Down Expand Up @@ -275,7 +277,9 @@ func installDcrdexBundleConfig() error {
}

// Check if the config file is already installed.
dir := dcrutil.AppDataDir(dexf[k].Name, false)
ext := filepath.Ext(dexf[k].Config)
name := strings.TrimSuffix(dexf[k].Config, ext)
dir := dcrutil.AppDataDir(name, false)
dst := filepath.Join(dir, dexf[k].Config)
if exists(dst) {
continue
Expand Down
14 changes: 11 additions & 3 deletions cmd/dcrinstall/decred.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ const (

// decredFiles provides all needed bits to perform the install the decred
// bundle.
//
// Note: The Config filename determines the target directory name. This is a
// necessary override where some daemons names end in d but the target
// directory and config file do not have the trailing d in the name.
type decredFiles struct {
Name string // Binary filename
Config string // Actual config file
Config string // Actual config file.
SampleFilename string // Sample file config file
SampleMemory string // Static sample config
SupportsVersion bool // Whether or not it supports --version
Expand Down Expand Up @@ -284,7 +288,9 @@ func preconditionsDecredInstall() error {

expectedConfigFiles++

dir := dcrutil.AppDataDir(df[k].Name, false)
ext := filepath.Ext(df[k].Config)
name := strings.TrimSuffix(df[k].Config, ext)
dir := dcrutil.AppDataDir(name, false)
filename := filepath.Join(dir, df[k].Config)
if exists(filename) {
log.Printf("Config %s -- already installed", filename)
Expand Down Expand Up @@ -408,7 +414,9 @@ func installDecredBundleConfig() error {
}

// Check if the config file is already installed.
dir := dcrutil.AppDataDir(df[k].Name, false)
ext := filepath.Ext(df[k].Config)
name := strings.TrimSuffix(df[k].Config, ext)
dir := dcrutil.AppDataDir(name, false)
dst := filepath.Join(dir, df[k].Config)
if exists(dst) {
continue
Expand Down

0 comments on commit 1a550ba

Please sign in to comment.