Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong DataDir error on Windows for Knots #12688

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NBitcoin;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Bases;
Expand Down Expand Up @@ -49,7 +50,12 @@
string processPath = MicroserviceHelpers.GetBinaryPath("bitcoind");
string networkArgument = NetworkTranslator.GetCommandLineArguments(Network);

string args = $"{networkArgument} -datadir=\"{DataDir}\" -printtoconsole={ptcv}";
// On Windows, if DataDir ends with '\', the Process can't be started.
string dataDir = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && DataDir.EndsWith('\\')
? DataDir[..^1]
: DataDir;

string args = $"{networkArgument} -datadir=\"{dataDir}\" -printtoconsole={ptcv}";

Check notice on line 58 in WalletWasabi/BitcoinCore/Processes/BitcoindRpcProcessBridge.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)

ℹ Getting worse: Complex Method

StartAsync increases in cyclomatic complexity from 9 to 11, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

// Start bitcoind process.
Process = new ProcessAsync(ProcessStartInfoFactory.Make(processPath, args));
Expand Down