mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Merge bitcoin/bitcoin#28075: util: Remove DirIsWritable, GetUniquePath
fa3da629a1Remove DirIsWritable, GetUniquePath (MarcoFalke)fad3a9793bReturn LockResult::ErrorWrite in LockDirectory (MarcoFalke)fa0afe7408refactor: Return enum in LockDirectory (MarcoFalke) Pull request description: `GetUniquePath` is only used in tests and in `DirIsWritable`. The check by `DirIsWritable` is redundant with the check done in `LockDirectory`. Fix the redundancy by removing everything, except `LockDirectory`. ACKs for top commit: TheCharlatan: Re-ACKfa3da629a1hebasto: ACKfa3da629a1, I have reviewed the code and it looks OK. Tree-SHA512: e95f18cd586de7582e9c08ac7ddb860bfcfcbc8963804f45c5784c5e4c0598dc59ae7e45dd4daf30a5020dbf8433f5db2ad06e46a8676371982003790043c6c9
This commit is contained in:
11
src/init.cpp
11
src/init.cpp
@@ -1047,13 +1047,14 @@ static bool LockDataDirectory(bool probeOnly)
|
||||
{
|
||||
// Make sure only a single Bitcoin process is using the data directory.
|
||||
const fs::path& datadir = gArgs.GetDataDirNet();
|
||||
if (!DirIsWritable(datadir)) {
|
||||
switch (util::LockDirectory(datadir, ".lock", probeOnly)) {
|
||||
case util::LockResult::ErrorWrite:
|
||||
return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions."), fs::PathToString(datadir)));
|
||||
}
|
||||
if (!LockDirectory(datadir, ".lock", probeOnly)) {
|
||||
case util::LockResult::ErrorLock:
|
||||
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. %s is probably already running."), fs::PathToString(datadir), PACKAGE_NAME));
|
||||
}
|
||||
return true;
|
||||
case util::LockResult::Success: return true;
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
assert(false);
|
||||
}
|
||||
|
||||
bool AppInitSanityChecks(const kernel::Context& kernel)
|
||||
|
||||
Reference in New Issue
Block a user