Refactor compareDatabases

This commit is contained in:
ProfessionalUwU 2023-06-26 17:21:56 +02:00
parent 6fbc53fa53
commit 944b61a1ac
Signed by: ProfessionalUwU
GPG Key ID: 9F28CB1645C4BFB5

View File

@ -208,7 +208,7 @@ public class ChksumUtils {
}
}
public void compareDatabases(string filePathToOtherDatabase) {
private List<string> getFilehashesOfOriginDatabase() {
List<string> filehashesOfOriginDatabase = new List<string>();
using (var connection = new SqliteConnection("Data Source=" + DatabaseRoot + "chksum.db;Mode=ReadOnly")) {
string filehash = string.Empty;
@ -229,6 +229,10 @@ public class ChksumUtils {
}
}
return filehashesOfOriginDatabase;
}
private List<string> getFilehashesOfRemoteDatabase(string filePathToOtherDatabase) {
List<string> filehashesOfRemoteDatabase = new List<string>();
using (var connection = new SqliteConnection("Data Source=" + filePathToOtherDatabase + ";Mode=ReadOnly")) {
string filehash = string.Empty;
@ -249,7 +253,11 @@ public class ChksumUtils {
}
}
List<string> filesThatDoNotExistsInTheRemote = filehashesOfOriginDatabase.Except(filehashesOfRemoteDatabase).ToList();
return filehashesOfRemoteDatabase;
}
public void compareDatabases(string filePathToOtherDatabase) {
List<string> filesThatDoNotExistsInTheRemote = getFilehashesOfOriginDatabase().Except(getFilehashesOfRemoteDatabase(filePathToOtherDatabase)).ToList();
//List<string> filesThatDoNotExistsInTheOrigin = filehashesOfRemoteDatabase.Except(filehashesOfOriginDatabase).ToList();
foreach (string file in filesThatDoNotExistsInTheRemote) {