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

Rename CurrentTargetTmp to TxTargetUser

The name reflects the functionality much better.
parent 10640754
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ namespace ATxCommon.Serializables ...@@ -22,7 +22,7 @@ namespace ATxCommon.Serializables
private string _statusDescription; private string _statusDescription;
private string _currentTransferSrc; private string _currentTransferSrc;
private string _currentTargetTmp; private string _txTargetUser;
private bool _transferInProgress; private bool _transferInProgress;
private bool _serviceSuspended; private bool _serviceSuspended;
...@@ -42,7 +42,7 @@ namespace ATxCommon.Serializables ...@@ -42,7 +42,7 @@ namespace ATxCommon.Serializables
/// </summary> /// </summary>
private ServiceStatus() { private ServiceStatus() {
_currentTransferSrc = ""; _currentTransferSrc = "";
_currentTargetTmp = ""; _txTargetUser = "";
_transferInProgress = false; _transferInProgress = false;
_transferredBytesCompleted = 0; _transferredBytesCompleted = 0;
_transferredBytesCurrentFile = 0; _transferredBytesCurrentFile = 0;
...@@ -183,15 +183,15 @@ namespace ATxCommon.Serializables ...@@ -183,15 +183,15 @@ namespace ATxCommon.Serializables
} }
/// <summary> /// <summary>
/// The name of the temporary folder being used for the currently running transfer, /// The user account name that should receive the data from the currently running transfer.
/// relative to "DestinationDirectory\TmpTransferDir" (i.e. the target username). See also /// See also <seealso cref="CurrentTargetTmpFull"/> on details for assembling the path that
/// <seealso cref="CurrentTargetTmpFull"/> on details for assembling the full path. /// is being used as a temporary location while a transfer is in progress.
/// </summary> /// </summary>
public string CurrentTargetTmp { public string TxTargetUser {
get => _currentTargetTmp; get => _txTargetUser;
set { set {
_currentTargetTmp = value; _txTargetUser = value;
Log.Trace("CurrentTargetTmp was updated ({0}).", value); Log.Trace("TxTargetUser was updated ({0}).", value);
Serialize(); Serialize();
} }
} }
...@@ -290,7 +290,7 @@ namespace ATxCommon.Serializables ...@@ -290,7 +290,7 @@ namespace ATxCommon.Serializables
/// <returns>A string with the path to the last tmp dir.</returns> /// <returns>A string with the path to the last tmp dir.</returns>
public string CurrentTargetTmpFull() { public string CurrentTargetTmpFull() {
return Path.Combine(_config.DestinationDirectory, return Path.Combine(_config.DestinationDirectory,
_currentTargetTmp, _txTargetUser,
_config.TmpTransferDir, _config.TmpTransferDir,
Environment.MachineName); Environment.MachineName);
} }
...@@ -331,13 +331,13 @@ namespace ATxCommon.Serializables ...@@ -331,13 +331,13 @@ namespace ATxCommon.Serializables
s.CurrentTransferSrc = ""; s.CurrentTransferSrc = "";
} }
// CurrentTargetTmp // TxTargetUser
var currentTargetTmpPath = s.CurrentTargetTmpFull(); var currentTargetTmpPath = s.CurrentTargetTmpFull();
if (s.CurrentTargetTmp.Length > 0 if (s.TxTargetUser.Length > 0
&& !Directory.Exists(currentTargetTmpPath)) { && !Directory.Exists(currentTargetTmpPath)) {
ReportInvalidStatus("CurrentTargetTmpPath", currentTargetTmpPath, ReportInvalidStatus("CurrentTargetTmpPath", currentTargetTmpPath,
"invalid temporary path of an unfinished transfer"); "invalid temporary path of an unfinished transfer");
s.CurrentTargetTmp = ""; s.TxTargetUser = "";
} }
} }
...@@ -356,7 +356,7 @@ namespace ATxCommon.Serializables ...@@ -356,7 +356,7 @@ namespace ATxCommon.Serializables
public string Summary() { public string Summary() {
return return
$"CurrentTransferSrc: {CurrentTransferSrc}\n" + $"CurrentTransferSrc: {CurrentTransferSrc}\n" +
$"CurrentTargetTmp: {CurrentTargetTmp}\n" + $"TxTargetUser: {TxTargetUser}\n" +
$"TransferInProgress: {TransferInProgress}\n" + $"TransferInProgress: {TransferInProgress}\n" +
$"CurrentTransferSize: {CurrentTransferSize}\n" + $"CurrentTransferSize: {CurrentTransferSize}\n" +
$"LastStatusUpdate: {LastStatusUpdate:yyyy-MM-dd HH:mm:ss}" + $"LastStatusUpdate: {LastStatusUpdate:yyyy-MM-dd HH:mm:ss}" +
......
...@@ -749,13 +749,13 @@ namespace ATxService ...@@ -749,13 +749,13 @@ namespace ATxService
if (_transferState != TxState.Stopped || _status.TransferInProgress) if (_transferState != TxState.Stopped || _status.TransferInProgress)
return; return;
if (_status.CurrentTargetTmp.Length > 0) { if (_status.TxTargetUser.Length > 0) {
Log.Debug("Finalizing transfer, cleaning up target storage location..."); Log.Debug("Finalizing transfer, cleaning up target storage location...");
var finalDst = DestinationPath(_status.CurrentTargetTmp); var finalDst = DestinationPath(_status.TxTargetUser);
if (!string.IsNullOrWhiteSpace(finalDst)) { if (!string.IsNullOrWhiteSpace(finalDst)) {
if (FsUtils.MoveAllSubDirs(new DirectoryInfo(_status.CurrentTargetTmpFull()), if (FsUtils.MoveAllSubDirs(new DirectoryInfo(_status.CurrentTargetTmpFull()),
finalDst, _config.EnforceInheritedACLs)) { finalDst, _config.EnforceInheritedACLs)) {
_status.CurrentTargetTmp = ""; _status.TxTargetUser = "";
} }
} }
} }
...@@ -803,10 +803,10 @@ namespace ATxService ...@@ -803,10 +803,10 @@ namespace ATxService
/// </summary> /// </summary>
private void ResumeInterruptedTransfer() { private void ResumeInterruptedTransfer() {
// CONDITIONS (a transfer has to be resumed): // CONDITIONS (a transfer has to be resumed):
// - CurrentTargetTmp has to be non-empty // - TxTargetUser has to be non-empty
// - TransferState has to be "Stopped" // - TransferState has to be "Stopped"
// - TransferInProgress must be true // - TransferInProgress must be true
if (_status.CurrentTargetTmp.Length <= 0 || if (_status.TxTargetUser.Length <= 0 ||
_transferState != TxState.Stopped || _transferState != TxState.Stopped ||
_status.TransferInProgress == false) _status.TransferInProgress == false)
return; return;
......
...@@ -10,12 +10,13 @@ namespace ATxService ...@@ -10,12 +10,13 @@ namespace ATxService
{ {
/// <summary> /// <summary>
/// Start transferring data from a given source directory to the destination /// 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 /// status "Stopped", sets CopyState to "Active" and FilecopyFinished to
/// false. The currently processed path is stored in the global status /// false. The currently processed path is stored in the global status
/// variable CurrentTransferSrc. /// variable CurrentTransferSrc.
/// </summary> /// </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) { private void StartTransfer(string sourcePath) {
// only proceed when in a valid state: // only proceed when in a valid state:
if (_transferState != TxState.Stopped) if (_transferState != TxState.Stopped)
...@@ -32,8 +33,8 @@ namespace ATxService ...@@ -32,8 +33,8 @@ namespace ATxService
_status.CurrentTransferSize = totalSize; _status.CurrentTransferSize = totalSize;
_status.CurrentTransferSrc = sourcePath; _status.CurrentTransferSrc = sourcePath;
// the user name is expected to be the last part of the path: // the user name is expected to be the last part of sourcePath:
_status.CurrentTargetTmp = new DirectoryInfo(sourcePath).Name; _status.TxTargetUser = new DirectoryInfo(sourcePath).Name;
FsUtils.CreateNewDirectory(_status.CurrentTargetTmpFull(), false); FsUtils.CreateNewDirectory(_status.CurrentTargetTmpFull(), false);
_transferState = TxState.Active; _transferState = TxState.Active;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment