diff --git a/ATxCommon/Serializables/ServiceStatus.cs b/ATxCommon/Serializables/ServiceStatus.cs index 5025a8977575d8bd6cddad145c9de6d831e3cb74..9404e2c2ec75db52587d9da9d71130a2ebef6a22 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 6f807fff5b349c511b62c1d3a8ce468a8bb6039d..27806a74988c1ab04f4495e0e50ca527696ea744 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 0e06cda20cbd31417ea3339b2616f9a0a2c624e2..76b3b5b330fe391904ce4013e745e45ba9f9aa4d 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;