Compare commits

..

No commits in common. "787721381d33cbf456e7e794fdfbd2466ec3ac6a" and "7f6f4c5253fd2d6c2edfe77dea201133161958db" have entirely different histories.

View File

@ -91,12 +91,8 @@ public class ChksumUtils {
public void doTheThing() {
using (var connection = new SqliteConnection("Data Source=" + DatabaseRoot + "chksum.db;Mode=ReadWrite")) {
if (getTotalFileCount() < 1) {
return;
}
connection.Open();
if (getTotalFileCount() >= 1) {
Dictionary<string, string> fileHashes = CalculateChecksums(indexFiles());
foreach (var file in fileHashes) {
string absolutePathToFile = file.Key;
string fileName = Path.GetFileName(absolutePathToFile);
@ -104,6 +100,8 @@ public class ChksumUtils {
string fileHash = file.Value;
if (checkIfFileMovedAndUpdatePathToFile(fileHash, fileName, pathToFile) == false && checkIfFileAlreadyExistsInDatabase(fileHash, fileName) == false) {
connection.Open();
var command = connection.CreateCommand();
command.CommandText =
@"
@ -118,6 +116,7 @@ public class ChksumUtils {
}
}
}
}
private bool checkIfFileAlreadyExistsInDatabase(string fileHash, string pathToFile) {
string filehash = string.Empty;
@ -185,9 +184,9 @@ public class ChksumUtils {
Console.WriteLine($"\tto \t{pathtofile}\n");
wasMoved = true;
}
}
return wasMoved;
}
}
public void checkIfFileWasDeleted() {
string pathToFile = string.Empty;
@ -205,9 +204,7 @@ public class ChksumUtils {
while (reader.Read()) {
pathToFile = reader.GetString(0);
if (File.Exists(pathToFile)) {
continue;
}
if (!File.Exists(pathToFile)) {
var deleteCommand = connection.CreateCommand();
deleteCommand.CommandText =
@"
@ -223,6 +220,7 @@ public class ChksumUtils {
}
}
}
}
private List<string> getFilehashesFromDatabase(string connectionString) {
List<string> filehashesFromDatabase = new List<string>();