Find new packages
We find new packages by getting the folder names in the DBPath local
This commit is contained in:
parent
a03dffabb7
commit
422909352e
@ -3,8 +3,8 @@ using System.Text.RegularExpressions;
|
|||||||
|
|
||||||
namespace Pacserver.Utils;
|
namespace Pacserver.Utils;
|
||||||
public class PacserverUtils {
|
public class PacserverUtils {
|
||||||
public string pacmanCacheDirectory { get; set; } = string.Empty;
|
public string pacmanCacheDirectory = string.Empty;
|
||||||
public static string pacmanDatabaseDirectory { get; set; } = string.Empty;
|
public static string pacmanDatabaseDirectory = string.Empty;
|
||||||
public static List<String> pathsToDetermine = new List<String>() { "CacheDir", "DBPath" };
|
public static List<String> pathsToDetermine = new List<String>() { "CacheDir", "DBPath" };
|
||||||
public void readPacmanConfig() {
|
public void readPacmanConfig() {
|
||||||
using (StreamReader file = new StreamReader("/etc/pacman.conf")) {
|
using (StreamReader file = new StreamReader("/etc/pacman.conf")) {
|
||||||
@ -36,8 +36,22 @@ public class PacserverUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkForNewerPackagesAndDatabases() {
|
private List<String> packageNamesAndVersion = new List<String>();
|
||||||
|
public void getEveryPackageNameAndVersionViaFolderName(string filePath) {
|
||||||
|
string[] directories = Directory.GetDirectories(pacmanDatabaseDirectory + "local/");
|
||||||
|
foreach (string directory in directories) {
|
||||||
|
packageNamesAndVersion.Add(new DirectoryInfo(directory).Name);
|
||||||
|
}
|
||||||
|
File.WriteAllLines(filePath, packageNamesAndVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> newerPackages = new List<String>();
|
||||||
|
public void checkForNewerPackages() {
|
||||||
|
if (File.Exists("/tmp/before_update.txt") && File.Exists("/tmp/after_update.txt")) {
|
||||||
|
newerPackages = File.ReadAllLines("/tmp/after_update.txt").Except(File.ReadLines("/tmp/before_update.txt")).ToList();
|
||||||
|
} else {
|
||||||
|
throw new FileNotFoundException("Necessary files could not be found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> newerPackagesAndDatabases = new List<String>();
|
private static List<String> newerPackagesAndDatabases = new List<String>();
|
||||||
|
@ -10,12 +10,25 @@ public class Program {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PacserverUtils utils = new PacserverUtils();
|
||||||
|
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "determinePacmanCacheDirectory":
|
case "determinePacmanCacheDirectory":
|
||||||
PacserverUtils utils = new PacserverUtils();
|
|
||||||
utils.readPacmanConfig();
|
utils.readPacmanConfig();
|
||||||
Console.WriteLine(utils.pacmanCacheDirectory);
|
Console.WriteLine(utils.pacmanCacheDirectory);
|
||||||
break;
|
break;
|
||||||
|
case "before":
|
||||||
|
utils.readPacmanConfig();
|
||||||
|
utils.getEveryPackageNameAndVersionViaFolderName("/tmp/before_update.txt");
|
||||||
|
break;
|
||||||
|
case "after":
|
||||||
|
utils.readPacmanConfig();
|
||||||
|
utils.getEveryPackageNameAndVersionViaFolderName("/tmp/after_update.txt");
|
||||||
|
break;
|
||||||
|
case "diff":
|
||||||
|
utils.checkForNewerPackages();
|
||||||
|
Console.WriteLine(utils.newerPackages);
|
||||||
|
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.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user