Skip to content

Commit ff3c88a

Browse files
implement UpdateAccessPath's and DestinationPath formatting for AbstractProvider
1 parent d27705c commit ff3c88a

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

FileSyncLibNet/SyncProviders/AbstractProvider.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,23 @@ public AbstractProvider(IFileJobOptions jobOptions) : base(jobOptions)
1818
throw new ArgumentException("this instance has no information about syncing files, it has type " + JobOptions.GetType().ToString());
1919
if (syncJobOptions.SourcePath.StartsWith("scp:"))
2020
{
21-
SourceAccess = new ScpAccessProvider(syncJobOptions.SourcePath, syncJobOptions.Credentials);
21+
SourceAccess = new ScpAccessProvider(syncJobOptions.Credentials);
22+
2223
}
2324
else
2425
{
25-
SourceAccess = new FileIoAccessProvider(syncJobOptions.SourcePath);
26+
SourceAccess = new FileIoAccessProvider();
2627
}
28+
SourceAccess.UpdateAccessPath(syncJobOptions.SourcePath);
2729
if (syncJobOptions.DestinationPath.StartsWith("scp:"))
2830
{
29-
DestinationAccess = new ScpAccessProvider(syncJobOptions.DestinationPath, syncJobOptions.Credentials);
31+
DestinationAccess = new ScpAccessProvider(syncJobOptions.Credentials);
3032
}
3133
else
3234
{
33-
DestinationAccess = new FileIoAccessProvider(syncJobOptions.DestinationPath);
35+
DestinationAccess = new FileIoAccessProvider();
3436
}
37+
3538
}
3639

3740
public override void DeleteFiles()
@@ -46,6 +49,8 @@ public override void SyncSourceToDest()
4649
var sw = Stopwatch.StartNew();
4750
try
4851
{
52+
string formattedDestinationPath = string.Format(jobOptions.DestinationPath, DateTime.Now);
53+
DestinationAccess.UpdateAccessPath(formattedDestinationPath);
4954
DestinationAccess.CreateDirectory("");
5055
}
5156
catch (Exception ex) { logger?.LogError(ex, "exception creating destination directory {A}", jobOptions.DestinationPath); }

0 commit comments

Comments
 (0)