feature/SQlite #1
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
|
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
|
Run executable
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
LD_LIBRARY_PATH=/usr/local/lib ./Chksum
|
./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
|
|
@ -84,7 +84,7 @@ public class ChksumUtils {
|
|||||||
string pathToFile = Path.GetRelativePath(DatabaseRoot, absolutePathToFile);
|
string pathToFile = Path.GetRelativePath(DatabaseRoot, absolutePathToFile);
|
||||||
string fileHash = CalculateMD5(fileName);
|
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();
|
connection.Open();
|
||||||
|
|
||||||
var command = connection.CreateCommand();
|
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 filehash = string.Empty;
|
||||||
string pathtofile = string.Empty;
|
string pathtofile = string.Empty;
|
||||||
bool doesExist = false;
|
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();
|
connection.Open();
|
||||||
|
|
||||||
var command = connection.CreateCommand();
|
var command = connection.CreateCommand();
|
||||||
@ -128,9 +128,6 @@ public class ChksumUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fileHash == filehash) {
|
if (fileHash == filehash) {
|
||||||
Console.WriteLine("Duplicate files found:");
|
|
||||||
Console.WriteLine($"\toriginal\t{pathToFile}");
|
|
||||||
Console.WriteLine($"\tduplicate\t{pathtofile}\n");
|
|
||||||
doesExist = true;
|
doesExist = true;
|
||||||
}
|
}
|
||||||
return doesExist;
|
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())) {
|
foreach (var directory in Directory.GetDirectories(Directory.GetCurrentDirectory())) {
|
||||||
Directory.SetCurrentDirectory(directory); // Set new root
|
Directory.SetCurrentDirectory(directory); // Set new root
|
||||||
if (getFileCount() >= 1) {
|
if (getFileCount() >= 1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user