diff --git a/src/Pacserver.Tests/TransferFilesTest.cs b/src/Pacserver.Tests/TransferFilesTest.cs index f2249e6..f8c861d 100644 --- a/src/Pacserver.Tests/TransferFilesTest.cs +++ b/src/Pacserver.Tests/TransferFilesTest.cs @@ -4,7 +4,7 @@ namespace Pacserver.Tests; public class TranserFilesTest { [Fact] - public void transferPacmanCache_doesNotFail() { + public async void transferPacmanCache_doesNotFail() { // Arrange PacserverUtils utils = new PacserverUtils(); diff --git a/src/Pacserver/Pacserver.cs b/src/Pacserver/Pacserver.cs index e578501..d2b61e1 100644 --- a/src/Pacserver/Pacserver.cs +++ b/src/Pacserver/Pacserver.cs @@ -33,23 +33,22 @@ public partial class PacserverUtils { string? line; while ((line = file.ReadLine()) is not null) { - foreach (string path in pathsToDetermine.Where(path => line.Contains(path))) { + string cachePath = pathsToDetermine[0]; + string dbPath = pathsToDetermine[1]; + + if (line.Contains(cachePath) || line.Contains(dbPath)) { Match match = CacheDirOrDBPathRegex().Match(line); - if (match.Success) { - switch (path) { - case "CacheDir": - pacmanCacheDirectory = match.ToString(); - break; - case "DBPath": - pacmanDatabaseDirectory = match.ToString(); - break; - default: - throw new ArgumentException("Could not deal with " + match.ToString()); - } - } else { + + if(!match.Success) { string pathsToDetermineString = string.Join(",", pathsToDetermine); throw new DirectoryNotFoundException("Could not determine the necessary file paths: " + pathsToDetermineString); } + + if (line.Contains(cachePath)) { + pacmanCacheDirectory = match.ToString(); + } else if (line.Contains(dbPath)) { + pacmanDatabaseDirectory = match.ToString(); + } } } }