From e72810ca2c45acbe6a660d466bee8204545f5d04 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Thu, 20 Oct 2022 22:47:28 +0800 Subject: [PATCH] Temporary fix for sharing violation Sharing violation may occur when reindexing after deleting user added source, causing some uwp programs can't be indexed. Don't actually know why it happens. Try to fix it. --- Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 4ca6c9877..8c14335f9 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -60,8 +60,8 @@ namespace Flow.Launcher.Plugin.Program.Programs InitPackageVersion(namespaces); const uint noAttribute = 0x80; - const Stgm exclusiveRead = Stgm.Read | Stgm.ShareExclusive; - var hResult = SHCreateStreamOnFileEx(path, exclusiveRead, noAttribute, false, null, out IStream stream); + const Stgm nonExclusiveRead = Stgm.Read | Stgm.ShareDenyNone; + var hResult = SHCreateStreamOnFileEx(path, nonExclusiveRead, noAttribute, false, null, out IStream stream); if (hResult == Hresult.Ok) { @@ -85,7 +85,7 @@ namespace Flow.Launcher.Plugin.Program.Programs Apps = new List().ToArray(); } - if (Marshal.ReleaseComObject(stream) > 0) + if (stream != null && Marshal.ReleaseComObject(stream) > 0) { Log.Error("Flow.Launcher.Plugin.Program.Programs.UWP", "AppxManifest.xml was leaked"); } @@ -784,6 +784,7 @@ namespace Flow.Launcher.Plugin.Program.Programs { Read = 0x0, ShareExclusive = 0x10, + ShareDenyNone = 0x40 } private enum Hresult : uint