Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions SFTPSync/SFTPSync.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

using SFTPSyncLib;
using SFTPSyncLib;

namespace SFTPSync
{
Expand All @@ -14,23 +13,27 @@ static async Task Main(string[] args)
else
{
var director = new SyncDirector(args[3]);
List<RemoteSync> remoteSyncWorkers = new List<RemoteSync>();

Logger.LogInfo("Starting initial sync...");

foreach (var pattern in args[5].Split(';', StringSplitOptions.RemoveEmptyEntries))
{
if (remoteSyncWorkers.Count > 0)
var remoteSync = new RemoteSync(
new RemoteSyncOptions
{
await remoteSyncWorkers[0].DoneMakingFolders;
}
remoteSyncWorkers.Add(new RemoteSync(args[0], args[1], args[2], args[3], args[4], pattern, remoteSyncWorkers.Count == 0, director, null, false, remoteSyncWorkers.Count == 0));
Host = args[0],
Username = args[1],
Password = args[2],
LocalRootDirectory = args[3],
RemoteRootDirectory = args[4],
SearchPatterns = args[5].Split(';', StringSplitOptions.RemoveEmptyEntries)
.Select(pattern => pattern.Trim())
.Where(pattern => pattern.Length > 0)
.ToArray()
},
director);

director.Start();

Logger.LogInfo($"Started sync worker {remoteSyncWorkers.Count} for pattern {pattern}");
}
Logger.LogInfo("Starting initial sync...");

//Wait for all sync workers to finish initial sync then tell the user
await Task.WhenAll(remoteSyncWorkers.Select(rsw => rsw.DoneInitialSync));
await remoteSync.InitialSyncAsync();

Logger.LogInfo("Initial sync complete, real-time sync active");

Expand All @@ -46,14 +49,11 @@ static async Task Main(string[] args)
}
}

foreach (var remoteSync in remoteSyncWorkers)
try
{
try
{
remoteSync.Dispose();
}
catch { }
remoteSync.Dispose();
}
catch { }
}
}
}
Expand Down
Loading