From bf6ef50850bdd1a97947921d657a1e38f2fa3c25 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Fri, 2 Mar 2018 16:58:41 +0100 Subject: [PATCH] Cover completed RoboCopy call without any files transferred. Try to move the corresponding transfer package out of the processing location to prevent it from being picked up again and producing the same problem again, move it to the error location instead and reset the transfer variables. --- ATxService/AutoTx.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs index b85f3c6..1bfd61b 100644 --- a/ATxService/AutoTx.cs +++ b/ATxService/AutoTx.cs @@ -689,6 +689,33 @@ namespace ATxService } if (_status.CurrentTransferSrc.Length > 0) { + if (_transferredFiles.Count == 0) { + var msg = "FinalizeTransfers: CurrentTransferSrc is set to " + + $"[{_status.CurrentTransferSrc}], but the list of transferred " + + "files is empty!\nThis indicates something went wrong during the " + + "transfer, maybe a local permission problem?"; + Log.Warn(msg); + SendAdminEmail(msg, "Error in FinalizeTransfers()"); + try { + var preserve = _status.CurrentTransferSrc + .Replace(_config.ManagedPath, "") + .Replace(@"\", "___"); + preserve = Path.Combine(_config.ErrorPath, preserve); + var stale = new DirectoryInfo(_status.CurrentTransferSrc); + stale.MoveTo(preserve); + Log.Warn("Moved stale transfer source to [{0}]!", preserve); + } + catch (Exception ex) { + Log.Error("Preserving the stale transfer source [{0}] in [{1}] failed: {2}", + _status.CurrentTransferSrc, _config.ErrorPath, ex.Message); + } + + // reset current transfer variables: + _status.CurrentTransferSrc = ""; + _status.CurrentTransferSize = 0; + + return; + } Log.Debug("Finalizing transfer, moving local data to grace location..."); MoveToGraceLocation(); SendTransferCompletedMail(); -- GitLab