From 61ad64a0df9e4b8bb557dfb67cec02e1806eb603 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 26 Jan 2025 15:58:46 +0530 Subject: [PATCH] DnsApplicationManager: updated LoadAllApplications() to add logging entry. Updated UninstallApplication() to suppress and log errors for folder delete task. --- .../Dns/Applications/DnsApplicationManager.cs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/DnsServerCore/Dns/Applications/DnsApplicationManager.cs b/DnsServerCore/Dns/Applications/DnsApplicationManager.cs index 6b61a19c..806433d4 100644 --- a/DnsServerCore/Dns/Applications/DnsApplicationManager.cs +++ b/DnsServerCore/Dns/Applications/DnsApplicationManager.cs @@ -1,6 +1,6 @@ /* Technitium DNS Server -Copyright (C) 2023 Shreyas Zare (shreyas@technitium.com) +Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -188,18 +188,16 @@ namespace DnsServerCore.Dns.Applications { try { + _dnsServer.LogManager?.Write("DNS Server is loading DNS application: " + Path.GetFileName(applicationFolder)); + _ = await LoadApplicationAsync(applicationFolder, false); RefreshAppObjectLists(); - LogManager log = _dnsServer.LogManager; - if (log != null) - log.Write("DNS Server successfully loaded DNS application: " + Path.GetFileName(applicationFolder)); + _dnsServer.LogManager?.Write("DNS Server successfully loaded DNS application: " + Path.GetFileName(applicationFolder)); } catch (Exception ex) { - LogManager log = _dnsServer.LogManager; - if (log != null) - log.Write("DNS Server failed to load DNS application: " + Path.GetFileName(applicationFolder) + "\r\n" + ex.ToString()); + _dnsServer.LogManager?.Write("DNS Server failed to load DNS application: " + Path.GetFileName(applicationFolder) + "\r\n" + ex.ToString()); } }); } @@ -280,7 +278,16 @@ namespace DnsServerCore.Dns.Applications app.Dispose(); if (Directory.Exists(app.DnsServer.ApplicationFolder)) - Directory.Delete(app.DnsServer.ApplicationFolder, true); + { + try + { + Directory.Delete(app.DnsServer.ApplicationFolder, true); + } + catch (Exception ex) + { + _dnsServer.LogManager?.Write(ex); + } + } } }