Skip to content

Commit dc8f94e

Browse files
committed
Added tests
Added lots of refactorings based on test output
1 parent 87a71f8 commit dc8f94e

10 files changed

Lines changed: 916 additions & 384 deletions

File tree

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"request": "launch",
88
"preLaunchTask": "dotnet: build",
99
"program": "${workspaceFolder}/FolderSync/bin/Debug/net8.0/FolderSync.dll",
10-
"args": ["--syncPeriod=20", "1", "--sourceFolder", "/home/loanstone/veeam SyncFolders/SourceFolder/", "--destFolder", "../", "--log", "/home/loanstone/veeam SyncFolders/Logs/"],
10+
"args": ["--syncPeriod=20", "1", "--sourceFolder", "/home/loanstone/veeam SyncFolders/SourceFolder/", "--destFolder", "/home/loanstone/veeam SyncFolders/BackupFolder/", "--log", "/home/loanstone/veeam SyncFolders/Logs/"],
1111
"cwd": "${workspaceFolder}",
1212
"stopAtEntry": false
1313
}

FolderSync/Config.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace FolderSync
2+
{
3+
public class Config
4+
{
5+
public int SyncPeriod { get; set; }
6+
public string SourceFolder { get; set; }
7+
public string BackupFolder { get; set; }
8+
public string LogFilePath { get; set; }
9+
}
10+
}

FolderSync/FileProps.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Security.Cryptography;
2-
using System.Security.Cryptography.X509Certificates;
32

43
namespace FolderSync
54
{
@@ -18,25 +17,17 @@ public FileProps(string absoluteFilePath, string root)
1817
_fileName = Path.GetFileName(absoluteFilePath);
1918
_root = root;
2019
_absoluteFilePath = absoluteFilePath;
21-
_relativeFilePath = absoluteFilePath.Replace(root, "");
20+
_relativeFilePath = Path.GetRelativePath(root, absoluteFilePath);
2221
_absolutePath = Path.GetDirectoryName(absoluteFilePath);
23-
_relativePath = _relativeFilePath.Replace(_fileName, "");
24-
_md5Code = Calculatemd5(absoluteFilePath);
25-
// using (var md5 = MD5.Create())
26-
// {
27-
// using (var stream = File.OpenRead(_absoluteFilePath))
28-
// {
29-
// var hash = md5.ComputeHash(stream);
30-
// _md5Code = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
31-
// }
32-
// }
22+
_relativePath = Path.GetDirectoryName(_relativeFilePath);
23+
_md5Code = Calculatemd5();
3324
}
3425

35-
private string Calculatemd5(string absoluteFilePath)
26+
private string Calculatemd5()
3627
{
3728
using (var md5 = MD5.Create())
3829
{
39-
using (var stream = File.OpenRead(absoluteFilePath))
30+
using (var stream = File.OpenRead(this._absoluteFilePath))
4031
{
4132
var hash = md5.ComputeHash(stream);
4233
return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();

0 commit comments

Comments
 (0)