Local file system storage as default (#4386)

* Local file system storage as default

Checks whether or not a file storage has been set. If not, it sets the local file system storage as default.

* Ensure check gets run
This commit is contained in:
d11n
2022-12-12 12:28:24 +01:00
committed by GitHub
parent 484cf9d8a2
commit f2cb07ac95
3 changed files with 30 additions and 25 deletions

View File

@@ -19,6 +19,8 @@ using BTCPayServer.Plugins.PointOfSale.Models;
using BTCPayServer.Services;
using BTCPayServer.Services.Apps;
using BTCPayServer.Services.Stores;
using BTCPayServer.Storage.Models;
using BTCPayServer.Storage.Services.Providers.FileSystemStorage.Configuration;
using ExchangeSharp;
using Fido2NetLib.Objects;
using Microsoft.AspNetCore.Identity;
@@ -87,13 +89,15 @@ namespace BTCPayServer.Hosting
var settings = (await _Settings.GetSettingAsync<MigrationSettings>());
if (settings is null)
{
// If it is null, then it's the first run: let's skip all the migrations by migration flags to true
// If it is null, then it's the first run: let's skip all the migrations by setting flags to true
settings = new MigrationSettings() { MigratedInvoiceTextSearchPages = int.MaxValue, MigratedTransactionLabels = int.MaxValue };
foreach (var prop in settings.GetType().GetProperties().Where(p => p.CanWrite && p.PropertyType == typeof(bool)))
{
prop.SetValue(settings, true);
}
// Ensure these checks still get run
settings.CheckedFirstRun = false;
settings.FileSystemStorageAsDefault = false;
await _Settings.UpdateSetting(settings);
}
@@ -222,6 +226,21 @@ namespace BTCPayServer.Hosting
settings.MigrateWalletColors = true;
await _Settings.UpdateSetting(settings);
}
if (!settings.FileSystemStorageAsDefault)
{
var storageSettings = await _Settings.GetSettingAsync<StorageSettings>();
if (storageSettings is null)
{
storageSettings = new StorageSettings
{
Provider = StorageProvider.FileSystem,
Configuration = JObject.FromObject(new FileSystemStorageConfiguration())
};
await _Settings.UpdateSetting(storageSettings);
}
settings.FileSystemStorageAsDefault = true;
await _Settings.UpdateSetting(settings);
}
}
catch (Exception ex)
{