Skip to content

Commit 2b5d864

Browse files
committed
quick fix if a user decides to remove root directories
1 parent acea8e3 commit 2b5d864

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

FolderSync/SyncLogic.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ public SyncLogic(Config config)
1212

1313
public void RunInitialSync()
1414
{
15+
if(!Directory.Exists(Config.SourceFolder))
16+
throw new DirectoryNotFoundException($"Source folder '{Config.SourceFolder}' no longer exists");
17+
if(!Directory.Exists(Config.BackupFolder))
18+
throw new DirectoryNotFoundException($"Backup folder '{Config.BackupFolder}' no longer exists");
19+
if(!Directory.Exists(Config.LogFilePath))
20+
throw new DirectoryNotFoundException($"Log file path '{Config.LogFilePath}' no longer exists");
21+
1522
CheckForMissingDirs();
1623
CheckForDeletedFiles();
1724
CheckForDeletedDirs();
@@ -23,6 +30,12 @@ public void RunSyncLoop()
2330
{
2431
while (true)
2532
{
33+
if(!Directory.Exists(Config.SourceFolder))
34+
throw new DirectoryNotFoundException($"Source folder '{Config.SourceFolder}' no longer exists");
35+
if(!Directory.Exists(Config.BackupFolder))
36+
throw new DirectoryNotFoundException($"Backup folder '{Config.BackupFolder}' no longer exists");
37+
if(!Directory.Exists(Config.LogFilePath))
38+
throw new DirectoryNotFoundException($"Log file path '{Config.LogFilePath}' no longer exists");
2639
CheckForMissingDirs();
2740
CheckForModifiedFiles();
2841
CheckForCopiesInSource();

0 commit comments

Comments
 (0)