Skip to content

Commit 108c4b2

Browse files
committed
added RunSync method, removed autogenerated junk
1 parent 84cbb60 commit 108c4b2

2 files changed

Lines changed: 20 additions & 15 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", "-1", "--sourceFolder", "/home/loanstone/veeam SyncFolders/SourceFolder/", "--destFolder", "/home/loanstone/veeam SyncFolders/DestinationFolder/", "--log", "/home/loanstone/veeam SyncFolders/Logs/"],
10+
"args": ["--syncPeriod", "1", "--sourceFolder", "/home/loanstone/veeam SyncFolders/SourceFolder/", "--destFolder", "/home/loanstone/veeam SyncFolders/DestinationFolder/", "--log", "/home/loanstone/veeam SyncFolders/Logs/"],
1111
"cwd": "${workspaceFolder}",
1212
"stopAtEntry": false
1313
}

FolderSync/Program.cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.IO;
3-
using Microsoft.Extensions.Configuration;
4-
using System.Runtime.InteropServices;
1+
using Microsoft.Extensions.Configuration;
52
using System.Diagnostics.CodeAnalysis;
63

74
namespace FolderSync
@@ -16,21 +13,29 @@ public class FolderSync
1613
private static string backupRoot;
1714
[NotNull]
1815
private static string logFilePath;
19-
16+
2017

2118
public static void Main(string[] args)
2219
{
2320
IConfiguration config = new ConfigurationBuilder().AddCommandLine(args).Build();
2421
ParseArgs(config);
2522
InitalSync();
26-
CheckForMissingDirs();
27-
CheckForMoodifiedFiles();
28-
CheckForMovedFiles();
29-
CheckForCopiesInSource();
30-
CheckForMissingFiles();
31-
CheckForDeletedFiles();
32-
CheckForDeletedDirs();
33-
// Sync();
23+
RunSync();
24+
}
25+
26+
private static void RunSync()
27+
{
28+
while (true)
29+
{
30+
CheckForMissingDirs();
31+
CheckForMoodifiedFiles();
32+
CheckForMovedFiles();
33+
CheckForCopiesInSource();
34+
CheckForMissingFiles();
35+
CheckForDeletedFiles();
36+
CheckForDeletedDirs();
37+
System.Threading.Thread.Sleep(syncPeriod * 60000);
38+
}
3439
}
3540

3641
private static void ParseArgs(IConfiguration config)
@@ -131,7 +136,7 @@ private static void EditFile(FileProps sourceFile, FileProps backupFile)
131136
File.Copy(sourceFile.GetAbsoluteFilePath, fullBackupPath);
132137
Log(sourceFile.GetFileName, backupFile.GetAbsolutePath, Actions.edited);
133138
}
134-
139+
// check for move is still not working properly
135140
private static void CheckForMovedFiles()
136141
{
137142
List<FileProps> sourceFileList = GetAllFilesInDirectory(sourceRoot);

0 commit comments

Comments
 (0)