Refactor readPacmanConfig
Reduced indentation && increased readability
This commit is contained in:
parent
6892191275
commit
42fe907ec8
@ -4,7 +4,7 @@ namespace Pacserver.Tests;
|
|||||||
|
|
||||||
public class TranserFilesTest {
|
public class TranserFilesTest {
|
||||||
[Fact]
|
[Fact]
|
||||||
public void transferPacmanCache_doesNotFail() {
|
public async void transferPacmanCache_doesNotFail() {
|
||||||
// Arrange
|
// Arrange
|
||||||
PacserverUtils utils = new PacserverUtils();
|
PacserverUtils utils = new PacserverUtils();
|
||||||
|
|
||||||
|
@ -33,23 +33,22 @@ public partial class PacserverUtils {
|
|||||||
string? line;
|
string? line;
|
||||||
|
|
||||||
while ((line = file.ReadLine()) is not null) {
|
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);
|
Match match = CacheDirOrDBPathRegex().Match(line);
|
||||||
if (match.Success) {
|
|
||||||
switch (path) {
|
if(!match.Success) {
|
||||||
case "CacheDir":
|
|
||||||
pacmanCacheDirectory = match.ToString();
|
|
||||||
break;
|
|
||||||
case "DBPath":
|
|
||||||
pacmanDatabaseDirectory = match.ToString();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentException("Could not deal with " + match.ToString());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
string pathsToDetermineString = string.Join(",", pathsToDetermine);
|
string pathsToDetermineString = string.Join(",", pathsToDetermine);
|
||||||
throw new DirectoryNotFoundException("Could not determine the necessary file paths: " + pathsToDetermineString);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user