mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-18 05:41:42 +10:00
Effective config: auto-revert flag when toggled to original; fix stale cache after restore
- Flag options: when user toggles value back to original, clear pending change (same as revert button); trigger revert immediately on change so UI updates without blur - UiContext: add RevertFieldAsync so section can revert a field and refresh; section wires it to Session.RevertChange + StateHasChanged - RestoreAsync: call config cache Invalidate() after File.Copy so next read sees restored file (fixes validate-fail → restore showing pre-restore data)
This commit is contained in:
@@ -11,6 +11,7 @@ public sealed class EffectiveConfigSaveService : IEffectiveConfigSaveService
|
||||
{
|
||||
private readonly IDnsmasqConfigSetService _configSetService;
|
||||
private readonly IDnsmasqConfigService _configService;
|
||||
private readonly IConfigSetCache _configSetCache;
|
||||
private readonly IConfigValidationService _validationService;
|
||||
private readonly IReloadService _reloadService;
|
||||
private readonly ILogger<EffectiveConfigSaveService> _logger;
|
||||
@@ -18,12 +19,14 @@ public sealed class EffectiveConfigSaveService : IEffectiveConfigSaveService
|
||||
public EffectiveConfigSaveService(
|
||||
IDnsmasqConfigSetService configSetService,
|
||||
IDnsmasqConfigService configService,
|
||||
IConfigSetCache configSetCache,
|
||||
IConfigValidationService validationService,
|
||||
IReloadService reloadService,
|
||||
ILogger<EffectiveConfigSaveService> logger)
|
||||
{
|
||||
_configSetService = configSetService;
|
||||
_configService = configService;
|
||||
_configSetCache = configSetCache;
|
||||
_validationService = validationService;
|
||||
_reloadService = reloadService;
|
||||
_logger = logger;
|
||||
@@ -139,6 +142,7 @@ public sealed class EffectiveConfigSaveService : IEffectiveConfigSaveService
|
||||
|
||||
var managedPath = set.ManagedFilePath!;
|
||||
File.Copy(backupPath, managedPath, overwrite: true);
|
||||
_configSetCache.Invalidate();
|
||||
_logger.LogInformation("Restored managed config from backup: {BackupPath}", backupPath);
|
||||
|
||||
var restartResult = await _reloadService.ReloadAsync(ct);
|
||||
|
||||
Reference in New Issue
Block a user