Skip to content
Snippets Groups Projects
Commit 34e476d5 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Clean up processing location if moving a new candidate fails.

If a new directory is found in incoming but the move operation to
processing failed for some reason, the timestamp and username
directories (and potentially some partially moved data?) would remain
in processing. To prevent confusion about those "incomplete" transfer
candidates they are moved to the "ERROR" location.
parent 760442ff
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment