From 944b61a1ace562a703a8ca439b865ae69ae7b355 Mon Sep 17 00:00:00 2001 From: ProfessionalUwU Date: Mon, 26 Jun 2023 17:21:56 +0200 Subject: [PATCH] Refactor compareDatabases --- src/Chksum/chksum.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Chksum/chksum.cs b/src/Chksum/chksum.cs index 8b165a9..38fe66e 100644 --- a/src/Chksum/chksum.cs +++ b/src/Chksum/chksum.cs @@ -208,7 +208,7 @@ public class ChksumUtils { } } - public void compareDatabases(string filePathToOtherDatabase) { + private List getFilehashesOfOriginDatabase() { List filehashesOfOriginDatabase = new List(); 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 getFilehashesOfRemoteDatabase(string filePathToOtherDatabase) { List filehashesOfRemoteDatabase = new List(); using (var connection = new SqliteConnection("Data Source=" + filePathToOtherDatabase + ";Mode=ReadOnly")) { string filehash = string.Empty; @@ -249,7 +253,11 @@ public class ChksumUtils { } } - List filesThatDoNotExistsInTheRemote = filehashesOfOriginDatabase.Except(filehashesOfRemoteDatabase).ToList(); + return filehashesOfRemoteDatabase; + } + + public void compareDatabases(string filePathToOtherDatabase) { + List filesThatDoNotExistsInTheRemote = getFilehashesOfOriginDatabase().Except(getFilehashesOfRemoteDatabase(filePathToOtherDatabase)).ToList(); //List filesThatDoNotExistsInTheOrigin = filehashesOfRemoteDatabase.Except(filehashesOfOriginDatabase).ToList(); foreach (string file in filesThatDoNotExistsInTheRemote) {