mirror of
https://github.com/duplicati/duplicati.git
synced 2025-11-28 03:20:25 +08:00
This PR changes the termination signal to a `CancellationToken` instead of a `ManualResetEvent` as the former works better with async code. With this change there is no longer a thread being captured during each long poll operation. This fixes #6452
49 lines
No EOL
1.4 KiB
C#
49 lines
No EOL
1.4 KiB
C#
|
|
using Duplicati.Library.AutoUpdater;
|
|
using Duplicati.Library.Interface;
|
|
using Duplicati.WebserverCore.Abstractions;
|
|
namespace Duplicati.WebserverCore.Services;
|
|
|
|
/// <summary>
|
|
/// Application settings for the Duplicati server
|
|
/// </summary>
|
|
public class ApplicationSettings : IApplicationSettings
|
|
{
|
|
/// <summary>
|
|
/// The application exit event
|
|
/// </summary>
|
|
private readonly CancellationTokenSource _applicationExitEvent = new();
|
|
/// <summary>
|
|
/// The folder where Duplicati data is stored
|
|
/// </summary>
|
|
private readonly string _dataFolder;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ApplicationSettings"/> class.
|
|
/// </summary>
|
|
public ApplicationSettings()
|
|
{
|
|
_dataFolder = DataFolderManager.GetDataFolder(DataFolderManager.AccessMode.ReadWritePermissionSet);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public bool SettingsEncryptionKeyProvidedExternally { get; set; }
|
|
|
|
/// <inheritdoc />
|
|
public Action? StartOrStopUsageReporter { get; set; }
|
|
|
|
/// <inheritdoc />
|
|
public string DataFolder => _dataFolder;
|
|
|
|
/// <inheritdoc />
|
|
public string Origin { get; set; } = "Server";
|
|
|
|
/// <inheritdoc />
|
|
public CancellationToken ApplicationExit => _applicationExitEvent.Token;
|
|
|
|
/// <inheritdoc />
|
|
public void SignalApplicationExit() => _applicationExitEvent.Cancel();
|
|
|
|
/// <inheritdoc />
|
|
public ISecretProvider? SecretProvider { get; set; }
|
|
} |