Skip to content

Commit 36a87f3

Browse files
committed
feat: update PostgresBinaryLocator to improve executable search in common paths
1 parent 0be9f3a commit 36a87f3

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

FurLab.Core/Services/PostgresBinaryLocator.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,21 @@ public class PostgresBinaryLocator : IPostgresBinaryLocator
3737

3838
var commonPaths = new[]
3939
{
40-
@"C:\Program Files\PostgreSQL\*\bin",
41-
@"C:\PostgreSQL\*\bin"
40+
@"C:\Program Files\PostgreSQL",
41+
@"C:\PostgreSQL"
4242
};
4343

44-
foreach (var pattern in commonPaths)
44+
foreach (var basePath in commonPaths)
4545
{
46-
var directory = Path.GetDirectoryName(pattern);
47-
if (directory != null && Directory.Exists(directory))
46+
if (Directory.Exists(basePath))
4847
{
49-
var files = Directory.GetFiles(directory, $"{executableName}.exe", SearchOption.AllDirectories);
50-
if (files.Length > 0)
48+
foreach (var versionDir in Directory.GetDirectories(basePath))
5149
{
52-
return files[0];
50+
var exePath = Path.Combine(versionDir, "bin", $"{executableName}.exe");
51+
if (File.Exists(exePath))
52+
{
53+
return exePath;
54+
}
5355
}
5456
}
5557
}

0 commit comments

Comments
 (0)