From 22859d5053cf12f49f21ac7297b475c1481c6b43 Mon Sep 17 00:00:00 2001 From: Malte Kuhlmann <19255462+makuhlmann@users.noreply.github.com> Date: Tue, 12 Jul 2022 13:31:03 +0200 Subject: [PATCH] Ensure proper saving of settings on file shares On Windows file shares (DFS) with restricted WRITE_DAC permission, the method File.Replace results in a System.UnauthorizedAccessException, even when the user has full permissions to interact with the file and folder. This configuration can commonly be found in business environments. By setting the flag ignoreMetadataErrors to true, errors related to attributes and ACL are ignored. This results in the settings being saved correctly. Normal errors during file operation are not suppressed with this change, they should fail as usual. --- ShareX.HelpersLib/Settings/SettingsBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ShareX.HelpersLib/Settings/SettingsBase.cs b/ShareX.HelpersLib/Settings/SettingsBase.cs index 417db2e50..5f8962c66 100644 --- a/ShareX.HelpersLib/Settings/SettingsBase.cs +++ b/ShareX.HelpersLib/Settings/SettingsBase.cs @@ -157,7 +157,7 @@ private bool SaveInternal(string filePath) FileHelpers.CreateDirectory(BackupFolder); } - File.Replace(tempFilePath, filePath, backupFilePath); + File.Replace(tempFilePath, filePath, backupFilePath, true); } else { @@ -323,4 +323,4 @@ private static void Serializer_Error(object sender, Newtonsoft.Json.Serializatio } } } -} \ No newline at end of file +}