diff --git a/ATxCommon/FsUtils.cs b/ATxCommon/FsUtils.cs index a5ac9a2a79b34066f983d2f084c0826b010def94..865bfc53e68ccf30e38cb04c084cf8460800b436 100644 --- a/ATxCommon/FsUtils.cs +++ b/ATxCommon/FsUtils.cs @@ -224,6 +224,7 @@ namespace ATxCommon retval &= CheckForDirectory(Path.Combine(managed, "PROCESSING")); retval &= CheckForDirectory(Path.Combine(managed, "DONE")); retval &= CheckForDirectory(Path.Combine(managed, "UNMATCHED")); + retval &= CheckForDirectory(Path.Combine(managed, "ERROR")); return retval; } diff --git a/ATxCommon/Serializables/ServiceConfig.cs b/ATxCommon/Serializables/ServiceConfig.cs index c7e622a57aba46aba2317eb4a3db11947444b6e1..386ba4aff66d8385e71732f570aa110ed6854580 100644 --- a/ATxCommon/Serializables/ServiceConfig.cs +++ b/ATxCommon/Serializables/ServiceConfig.cs @@ -226,6 +226,13 @@ namespace ATxCommon.Serializables [XmlIgnore] public string UnmatchedPath => Path.Combine(ManagedPath, "UNMATCHED"); + /// <summary> + /// The full path to the directory for directories that were moved out of the way due to + /// any kind of error in processing them. + /// </summary> + [XmlIgnore] + public string ErrorPath => Path.Combine(ManagedPath, "ERROR"); + #endregion diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs index 58bd70b671af94b9a17a192104a017536b626cbf..b85f3c62e3a8b80ee073481f8c48e6f57efa5748 100644 --- a/ATxService/AutoTx.cs +++ b/ATxService/AutoTx.cs @@ -752,6 +752,20 @@ namespace ATxService return true; errMsg = $"unable to move [{userDir.FullName}]"; + // just to be safe, don't delete the failed directory from the processing location + // but move it to the error location (in case something has in fact been moved + // there already we have to make sure not to kill it): + var moveFromProcessing = new DirectoryInfo(Path.Combine(processingPath, timeStamp)); + try { + moveFromProcessing.MoveTo(Path.Combine(_config.ErrorPath, timeStamp)); + Log.Debug("Moved failed directory [{0}] out of processing to [{1}].", + moveFromProcessing.FullName, _config.ErrorPath); + } + catch (Exception ex) { + Log.Error("Moving [{0}] to [{1}] failed: {2}", + moveFromProcessing.FullName, _config.ErrorPath, ex.Message); + throw; + } } catch (Exception ex) { errMsg = ex.Message;