From 90f830199a9670e8a7c9342edfdbc1866ccd6fcc Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Fri, 15 Sep 2017 22:41:04 +0200
Subject: [PATCH] Check if DestinationDirectory and TmpTransferDir exist.

Refers to issue #7
---
 AutoTx/AutoTx.cs | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs
index 7bab749..ee469c5 100644
--- a/AutoTx/AutoTx.cs
+++ b/AutoTx/AutoTx.cs
@@ -168,6 +168,23 @@ namespace AutoTx
                     configInvalid = true;
                 }
 
+                // DestinationDirectory
+                if (!_config.DestinationDirectory.StartsWith(@"\\")) {
+                    writeLog("WARNING: DestinationDirectory is no UNC path!");
+                }
+                if (!Directory.Exists(_config.DestinationDirectory)) {
+                    writeLog("ERROR: can't find destination: " + _config.DestinationDirectory);
+                    configInvalid = true;
+                }
+
+                // TmpTransferDir
+                var tmpTransferPath = Path.Combine(_config.DestinationDirectory,
+                    _config.TmpTransferDir);
+                if (!Directory.Exists(tmpTransferPath)) {
+                    writeLog("ERROR: temporary transfer dir doesn't exist: " + tmpTransferPath);
+                    configInvalid = true;
+                }
+
                 // ServiceTimer
                 if (_config.ServiceTimer < 1000) {
                     writeLog("ERROR: ServiceTimer must not be smaller than 1000 ms!");
-- 
GitLab