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

Add GetDirectorySize method and CurrentTransferSize attribute to status.

parent 76cb10f3
Branches
Tags
No related merge requests found
......@@ -601,6 +601,7 @@ namespace AutoTx
try {
_status.CurrentTransferSrc = queued[0].GetDirectories()[0].FullName;
_status.CurrentTransferSize = GetDirectorySize(_status.CurrentTransferSrc);
}
catch (Exception ex) {
writeLog("Error checking for data to be transferred: " + ex.Message);
......@@ -651,6 +652,7 @@ namespace AutoTx
MoveToGraceLocation();
SendTransferCompletedMail();
_status.CurrentTransferSrc = ""; // cleanup completed, so reset CurrentTransferSrc
_status.CurrentTransferSize = 0;
_transferredFiles.Clear(); // empty the list of transferred files
}
}
......@@ -928,6 +930,17 @@ namespace AutoTx
_lastUserDirCheck = DateTime.Now;
}
/// <summary>
/// Recursively sum up size of all files under a given path.
/// </summary>
/// <param name="path"></param>
/// <returns>The total size in bytes.</returns>
public static long GetDirectorySize(string path) {
return new DirectoryInfo(path)
.GetFiles("*", SearchOption.AllDirectories)
.Sum(file => file.Length);
}
#endregion
}
......
......@@ -69,7 +69,8 @@ namespace AutoTx
_roboCommand.RetryOptions.RetryCount = 0;
_roboCommand.RetryOptions.RetryWaitTime = 2;
_roboCommand.Start();
writeLogDebug("Transfer started");
writeLogDebug("Transfer started, total size: " +
_status.CurrentTransferSize / MegaBytes + " MB");
}
catch (ManagementException ex) {
writeLog("Error in StartTransfer(): " + ex.Message);
......
......@@ -128,6 +128,8 @@ namespace AutoTx
bool _filecopyFinished;
private bool _cleanShutdown;
private long _currentTransferSize;
[XmlElement("LastStatusUpdate", DataType = "dateTime")]
public DateTime LastStatusUpdate {
get { return _lastStatusUpdate; }
......@@ -190,6 +192,16 @@ namespace AutoTx
}
}
public long CurrentTransferSize {
get { return _currentTransferSize; }
set
{
_currentTransferSize = value;
log("CurrentTransferSize was updated (" + value + "), calling Serialize()...");
Serialize();
}
}
public XmlStatus() {
_currentTransferSrc = "";
_currentTargetTmp = "";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment