Skip to content

Commit

Permalink
Add --cache-dir flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Dec 16, 2024
1 parent 642a6d4 commit d60943d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions counterparty-core/counterpartycore/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def float_range_checker(arg):
{"action": "store_true", "default": False, "help": "don't ask for confirmation"},
],
[("--data-dir",), {"default": None, "help": "the path to the data directory"}],
[("--cache-dir",), {"default": None, "help": "the path to the cache directory"}],
[
("--log-file",),
{"nargs": "?", "const": None, "default": False, "help": "log to the specified file"},
Expand Down
13 changes: 7 additions & 6 deletions counterparty-core/counterpartycore/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def initialise_log_config(

def initialise_config(
data_dir=None,
cache_dir=None,
testnet=False,
testcoin=False,
regtest=False,
Expand Down Expand Up @@ -193,9 +194,11 @@ def initialise_config(
os.makedirs(data_dir, mode=0o755)
config.DATA_DIR = data_dir

config.CACHE_DIR = appdirs.user_cache_dir(appauthor=config.XCP_NAME, appname=config.APP_NAME)
if not os.path.isdir(config.CACHE_DIR):
if not cache_dir:
cache_dir = appdirs.user_cache_dir(appauthor=config.XCP_NAME, appname=config.APP_NAME)
if not os.path.isdir(cache_dir):
os.makedirs(config.CACHE_DIR, mode=0o755)
config.CACHE_DIR = cache_dir

# testnet
if testnet:
Expand Down Expand Up @@ -245,10 +248,7 @@ def initialise_config(
config.DATABASE = os.path.join(data_dir, filename)

config.FETCHER_DB_OLD = os.path.join(os.path.dirname(config.DATABASE), f"fetcherdb{network}")
config.FETCHER_DB = os.path.join(
appdirs.user_cache_dir(appauthor=config.XCP_NAME, appname=config.APP_NAME),
f"fetcherdb{network}",
)
config.FETCHER_DB = os.path.join(config.CACHE_DIR, f"fetcherdb{network}")

config.STATE_DATABASE = os.path.join(os.path.dirname(config.DATABASE), f"state{network}.db")

Expand Down Expand Up @@ -627,6 +627,7 @@ def initialise_log_and_config(args, api=False):
# Configuration
init_args = {
"data_dir": args.data_dir,
"cache_dir": args.cache_dir,
"testnet": args.testnet,
"testcoin": args.testcoin,
"regtest": args.regtest,
Expand Down
1 change: 1 addition & 0 deletions counterparty-core/counterpartycore/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ def api_server_v2(request, cp_server):
"max_log_file_rotations": 20,
"log_exclude_filters": None,
"log_include_filters": None,
"cache_dir": None,
}
server_config = (
default_config
Expand Down
2 changes: 2 additions & 0 deletions release-notes/release-notes-v10.9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

## CLI

- Add `--cache-dir` flag

# Credits

- Ouziel Slama
Expand Down

0 comments on commit d60943d

Please sign in to comment.