Page MenuHomePhabricator

util: make GetDataDir read-only & create datadir only in bitcoind and bitcoin-qt
ClosedPublic

Authored by PiRK on May 21 2024, 14:15.

Details

Summary

Currently ArgsManager::GetDataDir() ensures it will always return a datadir by creating one if necessary. The function is shared between bitcoind bitcoin-qt and bitcoin-cli which results in the undesirable behaviour described in core#20070.

This PR splits out the part of the function which creates directories and adds it as a standalone function, only called as part of bitcoind and bitcoin-qt init, but not bitcoin-cli.

This changes behaviour of GetConfigFilePath which now always returns the
absolute path of the provided -conf argument.

This is a backport of core#27073

Depends on D16192

Test Plan

ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.May 21 2024, 14:15
Fabien requested changes to this revision.May 21 2024, 14:36
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/util/system.cpp
385 ↗(On Diff #47850)

Can you use the clang-tidy syntax ? It was not clear the code below is not duplicated

389 ↗(On Diff #47850)

dito

src/util/system.h
190 ↗(On Diff #47850)
This revision now requires changes to proceed.May 21 2024, 14:36
This revision is now accepted and ready to land.May 21 2024, 15:43