refactor: store data folder in OS appropriate location
If the environment variable `NIM_STATUS_CLIENT_DEV` is not empty then the `./data` dir is created/used relative to the current working directory, as was always the case prior to the changes introduced in this commit. `NIM_STATUS_CLIENT_DEV` is set to `t` when doing `make run`. To get the production behavior in development do: ``` $ NIM_STATUS_CLIENT_DEV="" make run ``` or on Windows in a Bash shell: ``` $ NIM_STATUS_CLIENT_DEV="" mingw32-make run ``` Closes #391
This commit is contained in:
parent
e82dbfb7c6
commit
b22b500d4f
9
Makefile
9
Makefile
|
@ -304,13 +304,18 @@ clean: | clean-common
|
||||||
|
|
||||||
run: rcc $(RUN_TARGET)
|
run: rcc $(RUN_TARGET)
|
||||||
|
|
||||||
|
NIM_STATUS_CLIENT_DEV ?= t
|
||||||
|
|
||||||
run-linux-or-macos:
|
run-linux-or-macos:
|
||||||
echo -e "\e[92mRunning:\e[39m bin/nim_status_client"
|
echo -e "\e[92mRunning:\e[39m bin/nim_status_client"
|
||||||
LD_LIBRARY_PATH="$(QT5_LIBDIR)" ./bin/nim_status_client
|
NIM_STATUS_CLIENT_DEV="$(NIM_STATUS_CLIENT_DEV)" \
|
||||||
|
LD_LIBRARY_PATH="$(QT5_LIBDIR)" \
|
||||||
|
./bin/nim_status_client
|
||||||
|
|
||||||
run-windows:
|
run-windows:
|
||||||
echo -e "\e[92mRunning:\e[39m bin/nim_status_client.exe"
|
echo -e "\e[92mRunning:\e[39m bin/nim_status_client.exe"
|
||||||
|
NIM_STATUS_CLIENT_DEV="$(NIM_STATUS_CLIENT_DEV)" \
|
||||||
PATH="$(shell pwd)"/"$(shell dirname "$(DOTHERSIDE)")":"$(PATH)" \
|
PATH="$(shell pwd)"/"$(shell dirname "$(DOTHERSIDE)")":"$(PATH)" \
|
||||||
./bin/nim_status_client
|
./bin/nim_status_client.exe
|
||||||
|
|
||||||
endif # "variables.mk" was not included
|
endif # "variables.mk" was not included
|
||||||
|
|
|
@ -38,7 +38,6 @@ proc ensureDir(dirname: string) =
|
||||||
proc initNode*() =
|
proc initNode*() =
|
||||||
ensureDir(DATADIR)
|
ensureDir(DATADIR)
|
||||||
ensureDir(KEYSTOREDIR)
|
ensureDir(KEYSTOREDIR)
|
||||||
ensureDir(NOBACKUPDIR)
|
|
||||||
|
|
||||||
discard $libstatus.initKeystore(KEYSTOREDIR)
|
discard $libstatus.initKeystore(KEYSTOREDIR)
|
||||||
|
|
||||||
|
@ -91,10 +90,10 @@ proc storeDerivedAccounts*(account: GeneratedAccount, password: string): MultiAc
|
||||||
"password": hashedPassword
|
"password": hashedPassword
|
||||||
}
|
}
|
||||||
let response = $libstatus.multiAccountStoreDerivedAccounts($multiAccount);
|
let response = $libstatus.multiAccountStoreDerivedAccounts($multiAccount);
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = Json.decode($response, MultiAccounts)
|
result = Json.decode($response, MultiAccounts)
|
||||||
except:
|
except:
|
||||||
let err = Json.decode($response, StatusGoError)
|
let err = Json.decode($response, StatusGoError)
|
||||||
raise newException(StatusGoException, "Error storing multiaccount derived accounts: " & err.error)
|
raise newException(StatusGoException, "Error storing multiaccount derived accounts: " & err.error)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
const GENERATED* = "generated"
|
const GENERATED* = "generated"
|
||||||
const SEED* = "seed"
|
const SEED* = "seed"
|
||||||
|
@ -178,6 +179,35 @@ var NODE_CONFIG* = %* {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const DATADIR* = "./data/"
|
let sep = if defined(windows): "\\" else: "/"
|
||||||
const KEYSTOREDIR* = "./data/keystore/"
|
|
||||||
const NOBACKUPDIR* = "./noBackup/"
|
let homeDir = getHomeDir()
|
||||||
|
|
||||||
|
let parentDir =
|
||||||
|
if getEnv("NIM_STATUS_CLIENT_DEV").string != "":
|
||||||
|
"."
|
||||||
|
elif homeDir == "":
|
||||||
|
"."
|
||||||
|
elif defined(macosx):
|
||||||
|
joinPath(homeDir, "Library", "Application Support")
|
||||||
|
elif defined(windows):
|
||||||
|
let targetDir = getEnv("LOCALAPPDATA").string
|
||||||
|
if targetDir == "":
|
||||||
|
joinPath(homeDir, "AppData", "Local")
|
||||||
|
else:
|
||||||
|
targetDir
|
||||||
|
else:
|
||||||
|
let targetDir = getEnv("XDG_CONFIG_HOME").string
|
||||||
|
if targetDir == "":
|
||||||
|
joinPath(homeDir, ".config")
|
||||||
|
else:
|
||||||
|
targetDir
|
||||||
|
|
||||||
|
let clientDir =
|
||||||
|
if parentDir != ".":
|
||||||
|
joinPath(parentDir, "Status")
|
||||||
|
else:
|
||||||
|
parentDir
|
||||||
|
|
||||||
|
let DATADIR* = joinPath(clientDir, "data") & sep
|
||||||
|
let KEYSTOREDIR* = joinPath(clientDir, "data", "keystore") & sep
|
||||||
|
|
Loading…
Reference in New Issue