Compare commits

...

2 Commits

2 changed files with 28 additions and 4 deletions

View File

@ -93,6 +93,24 @@ public class PacserverUtils {
} }
} }
public List<String> databasesToTransfer = new List<String>();
public void filterDiffOutputForDatabases() {
foreach (string database in diffOfPackagesOrDatabases) {
databasesToTransfer.Add(getDatabaseFromRegex(database, @"\/(?:[\w.-]+\/)*[\w.-]+(?:\.\w+)*\/*db")); // https://regex101.com/r/Wm5M0P/1
}
}
public string getDatabaseFromRegex(string input, string pattern) {
string match = string.Empty;
MatchCollection matchCollection = Regex.Matches(input, pattern);
foreach (Match matches in matchCollection) {
match = matches.Value;
}
return match;
}
private static List<String> newerPackagesAndDatabases = new List<String>(); private static List<String> newerPackagesAndDatabases = new List<String>();
public async void transferPacmanCache() { public async void transferPacmanCache() {
HttpClient client = new HttpClient(); HttpClient client = new HttpClient();

View File

@ -6,7 +6,7 @@ public class Program {
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Please specify an option."); Console.WriteLine("Please specify an option.");
Console.ResetColor(); Console.ResetColor();
Console.WriteLine("Possible options are: determinePacmanCacheDirectory, packagesBefore, packagesAfter, diffPackages, databasesBefore, databasesAfter, diffDatabases"); Console.WriteLine("Possible options are: determinePacmanCacheDirectory, packagesBefore, packagesAfter, diffPackages, databasesBefore, databasesAfter, diffDatabases, filter");
return; return;
} }
@ -27,7 +27,7 @@ public class Program {
break; break;
case "diffPackages": case "diffPackages":
utils.diff("/tmp/before_update.txt", "/tmp/after_update.txt"); utils.diff("/tmp/before_update.txt", "/tmp/after_update.txt");
string packages = string.Join(",", utils.diffOfPackagesOrDatabases); string packages = string.Join("\n", utils.diffOfPackagesOrDatabases);
Console.WriteLine(packages); Console.WriteLine(packages);
break; break;
case "databasesBefore": case "databasesBefore":
@ -40,14 +40,20 @@ public class Program {
break; break;
case "diffDatabases": case "diffDatabases":
utils.diff("/tmp/databases_before.txt", "/tmp/databases_after.txt"); utils.diff("/tmp/databases_before.txt", "/tmp/databases_after.txt");
string databases = string.Join(",", utils.diffOfPackagesOrDatabases); string databases = string.Join("\n", utils.diffOfPackagesOrDatabases);
Console.WriteLine(databases); Console.WriteLine(databases);
break; break;
case "filter":
utils.diff("/tmp/databases_before.txt", "/tmp/databases_after.txt");
utils.filterDiffOutputForDatabases();
string filteredDatabases = string.Join("\n", utils.databasesToTransfer);
Console.WriteLine(filteredDatabases);
break;
default: default:
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(args[0] + " is not a recognized option."); Console.WriteLine(args[0] + " is not a recognized option.");
Console.ResetColor(); Console.ResetColor();
Console.WriteLine("Possible options are: determinePacmanCacheDirectory"); Console.WriteLine("Possible options are: determinePacmanCacheDirectory, packagesBefore, packagesAfter, diffPackages, databasesBefore, databasesAfter, diffDatabases, filter");
break; break;
} }
} }