From f52125098fc9ca91a4894d84d21a2e4a617ceaf8 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Wed, 6 Jun 2018 22:31:32 +0200 Subject: [PATCH] Convert CurrentTargetTmpFull into get-only property TxTargetTmp --- ATxCommon/Serializables/ServiceStatus.cs | 23 +++++++++++++---------- ATxService/AutoTx.cs | 4 ++-- ATxService/RoboCommand.cs | 4 ++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/ATxCommon/Serializables/ServiceStatus.cs b/ATxCommon/Serializables/ServiceStatus.cs index 5025a89..9404e2c 100644 --- a/ATxCommon/Serializables/ServiceStatus.cs +++ b/ATxCommon/Serializables/ServiceStatus.cs @@ -184,7 +184,7 @@ namespace ATxCommon.Serializables /// <summary> /// 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 + /// See also <seealso cref="TxTargetTmp"/> on details for assembling the path that /// is being used as a temporary location while a transfer is in progress. /// </summary> public string TxTargetUser { @@ -282,18 +282,22 @@ namespace ATxCommon.Serializables } #endregion getter / setter methods - + + + #region getter only methods /// <summary> - /// Helper method to generate the full path of the current temp directory. + /// The full path of the current transfer's temp directory on the target storage. /// </summary> - /// <returns>A string with the path to the last tmp dir.</returns> - public string CurrentTargetTmpFull() { - return Path.Combine(_config.DestinationDirectory, + /// <returns>A string with the path to the current tmp dir.</returns> + public string TxTargetTmp => + Path.Combine(_config.DestinationDirectory, _txTargetUser, _config.TmpTransferDir, Environment.MachineName); - } + + #endregion getter only methods + /// <summary> /// Helper to set the service state, logging a message if the state has changed. @@ -332,10 +336,9 @@ namespace ATxCommon.Serializables } // TxTargetUser - var currentTargetTmpPath = s.CurrentTargetTmpFull(); if (s.TxTargetUser.Length > 0 - && !Directory.Exists(currentTargetTmpPath)) { - ReportInvalidStatus("CurrentTargetTmpPath", currentTargetTmpPath, + && !Directory.Exists(s.TxTargetTmp)) { + ReportInvalidStatus("CurrentTargetTmpPath", s.TxTargetTmp, "invalid temporary path of an unfinished transfer"); s.TxTargetUser = ""; } diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs index 6f807ff..27806a7 100644 --- a/ATxService/AutoTx.cs +++ b/ATxService/AutoTx.cs @@ -753,7 +753,7 @@ namespace ATxService Log.Debug("Finalizing transfer, cleaning up target storage location..."); var finalDst = DestinationPath(_status.TxTargetUser); if (!string.IsNullOrWhiteSpace(finalDst)) { - if (FsUtils.MoveAllSubDirs(new DirectoryInfo(_status.CurrentTargetTmpFull()), + if (FsUtils.MoveAllSubDirs(new DirectoryInfo(_status.TxTargetTmp), finalDst, _config.EnforceInheritedACLs)) { _status.TxTargetUser = ""; } @@ -812,7 +812,7 @@ namespace ATxService return; Log.Debug("Resuming interrupted transfer from [{0}] to [{1}]", - _status.CurrentTransferSrc, _status.CurrentTargetTmpFull()); + _status.CurrentTransferSrc, _status.TxTargetTmp); StartTransfer(_status.CurrentTransferSrc); } diff --git a/ATxService/RoboCommand.cs b/ATxService/RoboCommand.cs index 0e06cda..76b3b5b 100644 --- a/ATxService/RoboCommand.cs +++ b/ATxService/RoboCommand.cs @@ -35,7 +35,7 @@ namespace ATxService // the user name is expected to be the last part of sourcePath: _status.TxTargetUser = new DirectoryInfo(sourcePath).Name; - FsUtils.CreateNewDirectory(_status.CurrentTargetTmpFull(), false); + FsUtils.CreateNewDirectory(_status.TxTargetTmp, false); _transferState = TxState.Active; _status.TransferInProgress = true; @@ -49,7 +49,7 @@ namespace ATxService // copy options _roboCommand.CopyOptions.Source = sourcePath; - _roboCommand.CopyOptions.Destination = _status.CurrentTargetTmpFull(); + _roboCommand.CopyOptions.Destination = _status.TxTargetTmp; // limit the transfer bandwidth by waiting between packets: _roboCommand.CopyOptions.InterPacketGap = _config.InterPacketGap; -- GitLab