From 9806ff3cdfdf268f38f05639c5335350f0859dd5 Mon Sep 17 00:00:00 2001 From: Hendrik Mennen Date: Thu, 8 Aug 2024 20:26:39 +0200 Subject: [PATCH] prioritize local hardware packages --- .../Services/FpgaService.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/OneWare.UniversalFpgaProjectSystem/Services/FpgaService.cs b/src/OneWare.UniversalFpgaProjectSystem/Services/FpgaService.cs index fccc7184..9ce4d3c8 100644 --- a/src/OneWare.UniversalFpgaProjectSystem/Services/FpgaService.cs +++ b/src/OneWare.UniversalFpgaProjectSystem/Services/FpgaService.cs @@ -43,14 +43,17 @@ public FpgaService(IPaths paths, ILogger logger) public void RegisterFpgaPackage(IFpgaPackage fpga) { + var existing = FpgaPackages.FirstOrDefault(x => x.Name == fpga.Name); + + if (existing != null) FpgaPackages.Remove(existing); + FpgaPackages.InsertSorted(fpga, (x1, x2) => string.Compare(x1.Name, x2.Name, StringComparison.Ordinal)); } public void RegisterFpgaExtensionPackage(IFpgaExtensionPackage fpgaExtension) { var existing = FpgaExtensionPackages.FirstOrDefault(x => x.Name == fpgaExtension.Name); - - //Allow overwrite from folder + if (existing != null) FpgaExtensionPackages.Remove(existing); FpgaExtensionPackages.InsertSorted(fpgaExtension, @@ -119,7 +122,7 @@ public void LoadGenericHardware() try { - foreach (var packageDir in Directory.GetDirectories(HardwareDirectory)) + foreach (var packageDir in Directory.GetDirectories(HardwareDirectory).OrderBy(x => x != Path.Combine(HardwareDirectory, "Local"))) { var fpgaDir = Path.Combine(packageDir, "FPGA");