init: Factor out AppInitLockDataDirectory
Summary:
Alternative to #10818, alternative solution to #10815.
After this change: All the AppInit steps before and inclusive
AppInitLockDataDirectory must not have Shutdown() called in case of
failure. Only when AppInitMain fails, Shutdown should be called.
Changes the GUI and bitcoind code to consistently do this.
Backport of Core PR 10832.
Completes T426
Co-authored-by: Jason B. Cox <contact@jasonbcox.com>
Test Plan: ninja && test_runner.py
Reviewers: deadalnix, schancel, #bitcoin_abc
Reviewed By: deadalnix, #bitcoin_abc
Subscribers: teamcity
Differential Revision: https://reviews.bitcoinabc.org/D1928