Minor tweaks
This commit is contained in:
parent
8aec649781
commit
2d42842fb2
15
README.md
15
README.md
@ -39,19 +39,8 @@ Go to the publish folder
|
||||
cd src/Chksum/bin/Release/net7.0/linux-x64/publish
|
||||
```
|
||||
|
||||
Copy the libe_sqlite3.so to your /usr/local/lib or /usr/lib
|
||||
```bash
|
||||
cp libe_sqlite3.so /usr/local/lib
|
||||
```
|
||||
|
||||
Run executable
|
||||
|
||||
```bash
|
||||
LD_LIBRARY_PATH=/usr/local/lib ./Chksum
|
||||
```
|
||||
|
||||
Info
|
||||
|
||||
LD_LIBRARY_PATH=/usr/local/lib is needed to tell the executable where the library is located
|
||||
|
||||
Alternately you can put the libe_sqlite3.so into the same folder as the executable
|
||||
./Chksum
|
||||
```
|
@ -84,7 +84,7 @@ public class ChksumUtils {
|
||||
string pathToFile = Path.GetRelativePath(DatabaseRoot, absolutePathToFile);
|
||||
string fileHash = CalculateMD5(fileName);
|
||||
|
||||
if (checkIfFileMovedAndUpdatePathToFile(fileHash, fileName, pathToFile) == false && checkIfFileAlreadyExists(fileHash, fileName) == false) {
|
||||
if (checkIfFileMovedAndUpdatePathToFile(fileHash, fileName, pathToFile) == false && checkIfFileAlreadyExistsInDatabase(fileHash, fileName) == false) {
|
||||
connection.Open();
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
@ -104,12 +104,12 @@ public class ChksumUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private bool checkIfFileAlreadyExists(string fileHash, string pathToFile) {
|
||||
private bool checkIfFileAlreadyExistsInDatabase(string fileHash, string pathToFile) {
|
||||
string filehash = string.Empty;
|
||||
string pathtofile = string.Empty;
|
||||
bool doesExist = false;
|
||||
|
||||
using (var connection = new SqliteConnection("Data Source=" + DatabaseRoot + "chksum.db;Mode=ReadWrite")) {
|
||||
using (var connection = new SqliteConnection("Data Source=" + DatabaseRoot + "chksum.db;Mode=ReadOnly")) {
|
||||
connection.Open();
|
||||
|
||||
var command = connection.CreateCommand();
|
||||
@ -128,9 +128,6 @@ public class ChksumUtils {
|
||||
}
|
||||
|
||||
if (fileHash == filehash) {
|
||||
Console.WriteLine("Duplicate files found:");
|
||||
Console.WriteLine($"\toriginal\t{pathToFile}");
|
||||
Console.WriteLine($"\tduplicate\t{pathtofile}\n");
|
||||
doesExist = true;
|
||||
}
|
||||
return doesExist;
|
||||
@ -177,7 +174,7 @@ public class ChksumUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public void compareChecksums() {
|
||||
public void compareChecksums() { // reuse for database comparison
|
||||
foreach (var directory in Directory.GetDirectories(Directory.GetCurrentDirectory())) {
|
||||
Directory.SetCurrentDirectory(directory); // Set new root
|
||||
if (getFileCount() >= 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user