Fix formatting
This commit is contained in:
parent
64995434ab
commit
b05ddd5e18
@ -73,34 +73,34 @@ public class ChksumUtils {
|
|||||||
|
|
||||||
public void doTheThing() {
|
public void doTheThing() {
|
||||||
foreach (var directory in Directory.GetDirectories(Directory.GetCurrentDirectory())) using (var connection = new SqliteConnection("Data Source=" + DatabaseRoot + "chksum.db;Mode=ReadWrite")) {
|
foreach (var directory in Directory.GetDirectories(Directory.GetCurrentDirectory())) using (var connection = new SqliteConnection("Data Source=" + DatabaseRoot + "chksum.db;Mode=ReadWrite")) {
|
||||||
Directory.SetCurrentDirectory(directory); // Set new root
|
Directory.SetCurrentDirectory(directory); // Set new root
|
||||||
if (getFileCount() >= 1) {
|
if (getFileCount() >= 1) {
|
||||||
DirectoryInfo dir = new DirectoryInfo(Directory.GetCurrentDirectory());
|
DirectoryInfo dir = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||||
FileInfo[] files = dir.GetFiles();
|
FileInfo[] files = dir.GetFiles();
|
||||||
foreach (FileInfo file in files) {
|
foreach (FileInfo file in files) {
|
||||||
string fileName = file.Name;
|
string fileName = file.Name;
|
||||||
string absolutePathToFile = Path.GetFullPath(fileName);
|
string absolutePathToFile = Path.GetFullPath(fileName);
|
||||||
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 && checkIfFileAlreadyExists(fileHash, fileName) == false) {
|
||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
var command = connection.CreateCommand();
|
var command = connection.CreateCommand();
|
||||||
command.CommandText =
|
command.CommandText =
|
||||||
@"
|
@"
|
||||||
INSERT INTO file (filehash, filename, pathtofile)
|
INSERT INTO file (filehash, filename, pathtofile)
|
||||||
VALUES ($filehash, $filename, $pathtofile)
|
VALUES ($filehash, $filename, $pathtofile)
|
||||||
";
|
";
|
||||||
command.Parameters.AddWithValue("$filehash", fileHash);
|
command.Parameters.AddWithValue("$filehash", fileHash);
|
||||||
command.Parameters.AddWithValue("$filename", fileName);
|
command.Parameters.AddWithValue("$filename", fileName);
|
||||||
command.Parameters.AddWithValue("$pathtofile", pathToFile);
|
command.Parameters.AddWithValue("$pathtofile", pathToFile);
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doTheThing();
|
|
||||||
}
|
}
|
||||||
|
doTheThing();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool checkIfFileAlreadyExists(string fileHash, string pathToFile) {
|
private bool checkIfFileAlreadyExists(string fileHash, string pathToFile) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user