Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Sep 9, 2021
1 parent a39d1e0 commit c39f134
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions BTCPayServer/Controllers/ServerController.cs
@@ -1,6 +1,7 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -407,7 +408,7 @@ private async Task<List<SelectListItem>> GetAppSelectList()
return apps;
}

private static bool TryParseAsExternalService(TorService torService, out ExternalService? externalService)
private static bool TryParseAsExternalService(TorService torService, [MaybeNullWhen(false)] out ExternalService externalService)
{
externalService = null;
if (torService.ServiceType == TorServiceType.P2P)
Expand Down Expand Up @@ -1013,7 +1014,7 @@ public async Task<IActionResult> Emails(EmailsViewModel model, string command)
{
if (model.PasswordSet)
{
var settings = await _SettingsRepository.GetSettingAsync<EmailSettings>();
var settings = await _SettingsRepository.GetSettingAsync<EmailSettings>() ?? new EmailSettings();
model.Settings.Password = settings.Password;
}
if (!model.Settings.IsComplete())
Expand All @@ -1036,15 +1037,15 @@ public async Task<IActionResult> Emails(EmailsViewModel model, string command)
}
else if (command == "ResetPassword")
{
var settings = await _SettingsRepository.GetSettingAsync<EmailSettings>();
var settings = await _SettingsRepository.GetSettingAsync<EmailSettings>() ?? new EmailSettings();
settings.Password = null;
await _SettingsRepository.UpdateSetting(model.Settings);
TempData[WellKnownTempData.SuccessMessage] = "Email server password reset";
return RedirectToAction(nameof(Emails));
}
else // if(command == "Save")
{
var oldSettings = await _SettingsRepository.GetSettingAsync<EmailSettings>();
var oldSettings = await _SettingsRepository.GetSettingAsync<EmailSettings>() ?? new EmailSettings();
if (new EmailsViewModel(oldSettings).PasswordSet)
{
model.Settings.Password = oldSettings.Password;
Expand Down Expand Up @@ -1074,9 +1075,10 @@ public async Task<IActionResult> LogsView(string? file = null, int offset = 0)
else
{
var di = Directory.GetParent(_Options.LogFile);
if (di == null)
if (di is null)
{
TempData[WellKnownTempData.ErrorMessage] = "Could not load log files";
return View("Logs", vm);
}

var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(_Options.LogFile);
Expand Down

0 comments on commit c39f134

Please sign in to comment.