Skip to content

Commit 4d63895

Browse files
Formatting and use default for invalid programs
1 parent 32f7c59 commit 4d63895

File tree

1 file changed

+9
-13
lines changed
  • Plugins/Flow.Launcher.Plugin.Program/Programs

1 file changed

+9
-13
lines changed

Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,7 @@ private static Win32 Win32Program(string path)
227227
ProgramLogger.LogException($"|Win32|Win32Program|{path}" +
228228
$"|Permission denied when trying to load the program from {path}", e);
229229

230-
return new Win32()
231-
{
232-
Valid = false, Enabled = false
233-
};
230+
return Default;
234231
}
235232
}
236233

@@ -308,9 +305,9 @@ private static Win32 UrlProgram(string path, string[] protocols)
308305
{
309306
return program;
310307
}
311-
foreach(var protocol in protocols)
308+
foreach (var protocol in protocols)
312309
{
313-
if(url.StartsWith(protocol))
310+
if (url.StartsWith(protocol))
314311
{
315312
program.LnkResolvedPath = url;
316313
program.Valid = true;
@@ -347,10 +344,7 @@ private static Win32 ExeProgram(string path)
347344
ProgramLogger.LogException($"|Win32|ExeProgram|{path}" +
348345
$"|Permission denied when trying to load the program from {path}", e);
349346

350-
return new Win32()
351-
{
352-
Valid = false, Enabled = false
353-
};
347+
return Default;
354348
}
355349
}
356350

@@ -361,7 +355,8 @@ private static IEnumerable<string> ProgramPaths(string directory, string[] suffi
361355

362356
return Directory.EnumerateFiles(directory, "*", new EnumerationOptions
363357
{
364-
IgnoreInaccessible = true, RecurseSubdirectories = true
358+
IgnoreInaccessible = true,
359+
RecurseSubdirectories = true
365360
}).Where(x => suffixes.Contains(Extension(x)));
366361
}
367362

@@ -542,6 +537,7 @@ public static Win32[] All(Settings settings)
542537
var programs = Enumerable.Empty<Win32>();
543538
var suffixes = settings.GetSuffixes();
544539
var protocols = settings.GetProtocols();
540+
545541
var unregistered = UnregisteredPrograms(settings.ProgramSources, suffixes, protocols);
546542

547543
programs = programs.Concat(unregistered);
@@ -634,7 +630,7 @@ public static async Task MonitorDirectoryChangeAsync()
634630
await Task.Run(Main.IndexWin32Programs);
635631
}
636632
}
637-
633+
638634
public static void WatchDirectory(string directory)
639635
{
640636
if (!Directory.Exists(directory))
@@ -647,7 +643,7 @@ public static void WatchDirectory(string directory)
647643
watcher.Deleted += static (_, _) => indexQueue.Writer.TryWrite(default);
648644
watcher.EnableRaisingEvents = true;
649645
watcher.IncludeSubdirectories = true;
650-
646+
651647
Watchers.Add(watcher);
652648
}
653649

0 commit comments

Comments
 (0)