From de7e5ac6548f3e0a17d508189ff4340f7a945200 Mon Sep 17 00:00:00 2001 From: Maxhy Date: Thu, 7 Mar 2024 12:35:40 +0100 Subject: [PATCH] Add Dry Run option on publish --- KeyManager.Library.UI/Properties/Resources.Designer.cs | 9 +++++++++ KeyManager.Library.UI/Properties/Resources.fr.resx | 3 +++ KeyManager.Library.UI/Properties/Resources.resx | 3 +++ KeyManager.Library.UI/PublishKeyStoreDialog.xaml | 4 ++++ KeyManager.Library/KeyStore/KeyStore.cs | 9 ++++++++- KeyManager.Library/KeyStore/StoreOptions.cs | 7 +++++++ 6 files changed, 34 insertions(+), 1 deletion(-) diff --git a/KeyManager.Library.UI/Properties/Resources.Designer.cs b/KeyManager.Library.UI/Properties/Resources.Designer.cs index e3390f8..2ebd759 100644 --- a/KeyManager.Library.UI/Properties/Resources.Designer.cs +++ b/KeyManager.Library.UI/Properties/Resources.Designer.cs @@ -249,6 +249,15 @@ public class Resources { } } + /// + /// Looks up a localized string similar to Dry Run (don't store). + /// + public static string DryRun { + get { + return ResourceManager.GetString("DryRun", resourceCulture); + } + } + /// /// Looks up a localized string similar to Edit default key entry definition. /// diff --git a/KeyManager.Library.UI/Properties/Resources.fr.resx b/KeyManager.Library.UI/Properties/Resources.fr.resx index 586f23a..77f9b59 100644 --- a/KeyManager.Library.UI/Properties/Resources.fr.resx +++ b/KeyManager.Library.UI/Properties/Resources.fr.resx @@ -180,6 +180,9 @@ Disques + + Essai (ne pas sauvegarder) + Modifier la définition de l'enregistrement de clés par défaut diff --git a/KeyManager.Library.UI/Properties/Resources.resx b/KeyManager.Library.UI/Properties/Resources.resx index 7ad5beb..b831968 100644 --- a/KeyManager.Library.UI/Properties/Resources.resx +++ b/KeyManager.Library.UI/Properties/Resources.resx @@ -180,6 +180,9 @@ Drives + + Dry Run (don't store) + Edit default key entry definition diff --git a/KeyManager.Library.UI/PublishKeyStoreDialog.xaml b/KeyManager.Library.UI/PublishKeyStoreDialog.xaml index 5cc20c7..1c125f8 100644 --- a/KeyManager.Library.UI/PublishKeyStoreDialog.xaml +++ b/KeyManager.Library.UI/PublishKeyStoreDialog.xaml @@ -31,6 +31,10 @@ + + + + diff --git a/KeyManager.Library/KeyStore/KeyStore.cs b/KeyManager.Library/KeyStore/KeyStore.cs index f0f8170..689024f 100644 --- a/KeyManager.Library/KeyStore/KeyStore.cs +++ b/KeyManager.Library/KeyStore/KeyStore.cs @@ -345,7 +345,14 @@ public virtual async Task Publish(KeyStore store, Func getFav await store.Open(); try { - await store.Store(changes); + if (!(Options?.DryRun).GetValueOrDefault(false)) + { + await store.Store(changes); + } + else + { + log.Info("Dry Run, skipping key entries storing."); + } } finally { diff --git a/KeyManager.Library/KeyStore/StoreOptions.cs b/KeyManager.Library/KeyStore/StoreOptions.cs index 995d258..4b334f6 100644 --- a/KeyManager.Library/KeyStore/StoreOptions.cs +++ b/KeyManager.Library/KeyStore/StoreOptions.cs @@ -31,6 +31,13 @@ public bool ResolveKeyLinks set => SetProperty(ref _resolveKeyLinks, value); } + private bool _dryRun; + public bool DryRun + { + get => _dryRun; + set => SetProperty(ref _dryRun, value); + } + private string? _publishVariable; public string? PublishVariable {