From 760442ffcab10348455fb680656dac4f3e1cdaea Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Fri, 2 Mar 2018 15:30:58 +0100
Subject: [PATCH] Remember failed dirs in incoming and ignore them for the
 session.

Use a list to keep track of directories in the incoming directories that
couldn't be moved to the processing location and ignore them until the
service is restarted.
---
 ATxService/AutoTx.cs | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs
index 2f91cb7..58bd70b 100644
--- a/ATxService/AutoTx.cs
+++ b/ATxService/AutoTx.cs
@@ -30,6 +30,12 @@ namespace ATxService
         // private const string LogFormatDefault = @"${date:format=yyyy-MM-dd HH\:mm\:ss} [${level}] (${logger}) ${message}"
 
         private readonly List<string> _transferredFiles = new List<string>();
+        
+        /// <summary>
+        /// A list of (full) paths to be ignored in the incoming location, that will be populated
+        /// during runtime only, i.e. will not persist over a service restart (intentionally!).
+        /// </summary>
+        private readonly List<string> _incomingIgnore = new List<string>();
 
         private RoboCommand _roboCommand;
         private long _txCurFileSize;
@@ -643,8 +649,18 @@ namespace ATxService
                 if (FsUtils.DirEmptyExcept(userDir, _config.MarkerFile))
                     continue;
 
+                if (_incomingIgnore.Contains(userDir.FullName)) {
+                    Log.Trace("Ignoring directory in incoming location: [{0}]", userDir.FullName);
+                    continue;
+                }
+
                 Log.Info("Found new files in [{0}]", userDir.FullName);
-                MoveToManagedLocation(userDir);
+                if (MoveToManagedLocation(userDir))
+                    continue;
+
+                // if moving to the processing location failed, add it to the ignore list:
+                Log.Error("=== Ignoring [{0}] for this service session ===", userDir.FullName);
+                _incomingIgnore.Add(userDir.FullName);
             }
         }
 
-- 
GitLab