From dacd975100a3e86492c5b52f5d7436debe3eb2a0 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Thu, 18 Jan 2018 12:30:47 +0100 Subject: [PATCH] Move ExpandCurrentTargetTmp to ServiceStatus.CurrentTargetTmpFull. --- ATXCommon/Serializables/ServiceStatus.cs | 14 ++++++++++++-- AutoTx/AutoTx.cs | 15 +++------------ AutoTx/RoboCommand.cs | 4 ++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ATXCommon/Serializables/ServiceStatus.cs b/ATXCommon/Serializables/ServiceStatus.cs index acedcac..c2dbee9 100644 --- a/ATXCommon/Serializables/ServiceStatus.cs +++ b/ATXCommon/Serializables/ServiceStatus.cs @@ -19,8 +19,8 @@ namespace ATXCommon.Serializables private DateTime _lastGraceNotification; private string _limitReason; - string _currentTransferSrc; - string _currentTargetTmp; + private string _currentTransferSrc; + private string _currentTargetTmp; bool _transferInProgress; private bool _serviceSuspended; @@ -217,5 +217,15 @@ namespace ATXCommon.Serializables "LastGraceNotification: " + LastGraceNotification.ToString("yyyy-MM-dd HH:mm:ss") + "\n"; } + + /// <summary> + /// Helper method to generate the full path of the current temp directory. + /// </summary> + /// <returns>A string with the path to the last tmp dir.</returns> + public string CurrentTargetTmpFull() { + return Path.Combine(_config.DestinationDirectory, + _config.TmpTransferDir, + _currentTargetTmp); + } } } diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs index ae91a53..374b38c 100644 --- a/AutoTx/AutoTx.cs +++ b/AutoTx/AutoTx.cs @@ -509,16 +509,6 @@ namespace AutoTx #region transfer tasks - /// <summary> - /// Helper method to generate the full path of the current temp directory. - /// </summary> - /// <returns>A string with the path to the last tmp dir.</returns> - private string ExpandCurrentTargetTmp() { - return Path.Combine(_config.DestinationDirectory, - _config.TmpTransferDir, - _status.CurrentTargetTmp); - } - /// <summary> /// Assemble the transfer destination path and check if it exists. /// </summary> @@ -627,7 +617,8 @@ namespace AutoTx Log.Debug("Finalizing transfer, cleaning up target storage location..."); var finalDst = DestinationPath(_status.CurrentTargetTmp); if (!string.IsNullOrWhiteSpace(finalDst)) { - if (MoveAllSubDirs(new DirectoryInfo(ExpandCurrentTargetTmp()), finalDst, true)) { + if (MoveAllSubDirs(new DirectoryInfo(_status.CurrentTargetTmpFull()), + finalDst, true)) { _status.CurrentTargetTmp = ""; } } @@ -658,7 +649,7 @@ namespace AutoTx return; Log.Debug("Resuming interrupted transfer from [{0}] to [{1}]", - _status.CurrentTransferSrc, ExpandCurrentTargetTmp()); + _status.CurrentTransferSrc, _status.CurrentTargetTmpFull()); StartTransfer(_status.CurrentTransferSrc); } diff --git a/AutoTx/RoboCommand.cs b/AutoTx/RoboCommand.cs index 0078517..e36b403 100644 --- a/AutoTx/RoboCommand.cs +++ b/AutoTx/RoboCommand.cs @@ -27,7 +27,7 @@ namespace AutoTx // the user name is expected to be the last part of the path: _status.CurrentTargetTmp = new DirectoryInfo(sourcePath).Name; - CreateNewDirectory(ExpandCurrentTargetTmp(), false); + CreateNewDirectory(_status.CurrentTargetTmpFull(), false); _transferState = TxState.Active; _status.TransferInProgress = true; @@ -39,7 +39,7 @@ namespace AutoTx // copy options _roboCommand.CopyOptions.Source = sourcePath; - _roboCommand.CopyOptions.Destination = ExpandCurrentTargetTmp(); + _roboCommand.CopyOptions.Destination = _status.CurrentTargetTmpFull(); // limit the transfer bandwidth by waiting between packets: _roboCommand.CopyOptions.InterPacketGap = _config.InterPacketGap; -- GitLab