Return LockResult::ErrorWrite in LockDirectory

This allows the caller to remove a call to DirIsWritable(), which did a
similar check. Users should not notice any different behavior.
This commit is contained in:
MarcoFalke
2023-07-14 12:24:16 +02:00
parent fa0afe7408
commit fad3a9793b
4 changed files with 17 additions and 7 deletions

View File

@@ -1028,10 +1028,9 @@ 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)) {
return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions."), fs::PathToString(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)));
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));
case util::LockResult::Success: return true;