From 6194e1dc3c78c68315f01ab33d5b40d8953ea4a3 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Wed, 6 Jun 2018 16:48:03 +0200 Subject: [PATCH] Rename CurrentTargetTmp to TxTargetUser The name reflects the functionality much better. --- ATxCommon/Serializables/ServiceStatus.cs | 28 ++++++++++++------------ ATxService/AutoTx.cs | 10 ++++----- ATxService/RoboCommand.cs | 9 ++++---- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/ATxCommon/Serializables/ServiceStatus.cs b/ATxCommon/Serializables/ServiceStatus.cs index 39d8b53..5025a89 100644 --- a/ATxCommon/Serializables/ServiceStatus.cs +++ b/ATxCommon/Serializables/ServiceStatus.cs @@ -22,7 +22,7 @@ namespace ATxCommon.Serializables private string _statusDescription; private string _currentTransferSrc; - private string _currentTargetTmp; + private string _txTargetUser; private bool _transferInProgress; private bool _serviceSuspended; @@ -42,7 +42,7 @@ namespace ATxCommon.Serializables /// </summary> private ServiceStatus() { _currentTransferSrc = ""; - _currentTargetTmp = ""; + _txTargetUser = ""; _transferInProgress = false; _transferredBytesCompleted = 0; _transferredBytesCurrentFile = 0; @@ -183,15 +183,15 @@ namespace ATxCommon.Serializables } /// <summary> - /// The name of the temporary folder being used for the currently running transfer, - /// relative to "DestinationDirectory\TmpTransferDir" (i.e. the target username). See also - /// <seealso cref="CurrentTargetTmpFull"/> on details for assembling the full path. + /// The user account name that should receive the data from the currently running transfer. + /// See also <seealso cref="CurrentTargetTmpFull"/> on details for assembling the path that + /// is being used as a temporary location while a transfer is in progress. /// </summary> - public string CurrentTargetTmp { - get => _currentTargetTmp; + public string TxTargetUser { + get => _txTargetUser; set { - _currentTargetTmp = value; - Log.Trace("CurrentTargetTmp was updated ({0}).", value); + _txTargetUser = value; + Log.Trace("TxTargetUser was updated ({0}).", value); Serialize(); } } @@ -290,7 +290,7 @@ namespace ATxCommon.Serializables /// <returns>A string with the path to the last tmp dir.</returns> public string CurrentTargetTmpFull() { return Path.Combine(_config.DestinationDirectory, - _currentTargetTmp, + _txTargetUser, _config.TmpTransferDir, Environment.MachineName); } @@ -331,13 +331,13 @@ namespace ATxCommon.Serializables s.CurrentTransferSrc = ""; } - // CurrentTargetTmp + // TxTargetUser var currentTargetTmpPath = s.CurrentTargetTmpFull(); - if (s.CurrentTargetTmp.Length > 0 + if (s.TxTargetUser.Length > 0 && !Directory.Exists(currentTargetTmpPath)) { ReportInvalidStatus("CurrentTargetTmpPath", currentTargetTmpPath, "invalid temporary path of an unfinished transfer"); - s.CurrentTargetTmp = ""; + s.TxTargetUser = ""; } } @@ -356,7 +356,7 @@ namespace ATxCommon.Serializables public string Summary() { return $"CurrentTransferSrc: {CurrentTransferSrc}\n" + - $"CurrentTargetTmp: {CurrentTargetTmp}\n" + + $"TxTargetUser: {TxTargetUser}\n" + $"TransferInProgress: {TransferInProgress}\n" + $"CurrentTransferSize: {CurrentTransferSize}\n" + $"LastStatusUpdate: {LastStatusUpdate:yyyy-MM-dd HH:mm:ss}" + diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs index edca7f8..6f807ff 100644 --- a/ATxService/AutoTx.cs +++ b/ATxService/AutoTx.cs @@ -749,13 +749,13 @@ namespace ATxService if (_transferState != TxState.Stopped || _status.TransferInProgress) return; - if (_status.CurrentTargetTmp.Length > 0) { + if (_status.TxTargetUser.Length > 0) { Log.Debug("Finalizing transfer, cleaning up target storage location..."); - var finalDst = DestinationPath(_status.CurrentTargetTmp); + var finalDst = DestinationPath(_status.TxTargetUser); if (!string.IsNullOrWhiteSpace(finalDst)) { if (FsUtils.MoveAllSubDirs(new DirectoryInfo(_status.CurrentTargetTmpFull()), finalDst, _config.EnforceInheritedACLs)) { - _status.CurrentTargetTmp = ""; + _status.TxTargetUser = ""; } } } @@ -803,10 +803,10 @@ namespace ATxService /// </summary> private void ResumeInterruptedTransfer() { // CONDITIONS (a transfer has to be resumed): - // - CurrentTargetTmp has to be non-empty + // - TxTargetUser has to be non-empty // - TransferState has to be "Stopped" // - TransferInProgress must be true - if (_status.CurrentTargetTmp.Length <= 0 || + if (_status.TxTargetUser.Length <= 0 || _transferState != TxState.Stopped || _status.TransferInProgress == false) return; diff --git a/ATxService/RoboCommand.cs b/ATxService/RoboCommand.cs index 113e100..0e06cda 100644 --- a/ATxService/RoboCommand.cs +++ b/ATxService/RoboCommand.cs @@ -10,12 +10,13 @@ namespace ATxService { /// <summary> /// Start transferring data from a given source directory to the destination - /// location that is stored in CurrentTargetTmp. Requires CopyState to be in + /// location that is derived from TxTargetUser. Requires CopyState to be in /// status "Stopped", sets CopyState to "Active" and FilecopyFinished to /// false. The currently processed path is stored in the global status /// variable CurrentTransferSrc. /// </summary> - /// <param name="sourcePath">The full path to a folder.</param> + /// <param name="sourcePath">The full path to a folder. By convention, the + /// LAST element of the path has to match the target user name!</param> private void StartTransfer(string sourcePath) { // only proceed when in a valid state: if (_transferState != TxState.Stopped) @@ -32,8 +33,8 @@ namespace ATxService _status.CurrentTransferSize = totalSize; _status.CurrentTransferSrc = sourcePath; - // the user name is expected to be the last part of the path: - _status.CurrentTargetTmp = new DirectoryInfo(sourcePath).Name; + // the user name is expected to be the last part of sourcePath: + _status.TxTargetUser = new DirectoryInfo(sourcePath).Name; FsUtils.CreateNewDirectory(_status.CurrentTargetTmpFull(), false); _transferState = TxState.Active; -- GitLab