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

Convert CurrentTargetTmpFull into get-only property TxTargetTmp

parent 6194e1dc
No related branches found
No related tags found
No related merge requests found
......@@ -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 = "";
}
......
......@@ -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);
}
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment