1
0
mirror of https://github.com/Ylianst/MeshCentralRouter synced 2025-12-06 00:13:33 +00:00

Fixed upload time estimate if file is resumed.

This commit is contained in:
Ylian Saint-Hilaire
2021-10-17 14:35:14 -07:00
parent 9a8b6c39d3
commit 20bb296dcb
2 changed files with 12 additions and 4 deletions

View File

@@ -86,13 +86,13 @@ namespace MeshCentralRouter
double elapseTimeSeconds = DateTime.Now.Subtract(fileViewer.uploadFileStartTime).TotalMilliseconds / 1000;
if (elapseTimeSeconds < 5) { mainLabel2.Text = Translate.T(Properties.Resources.EstimatingDotDotDot); } else
{
double bytePerSecond = x / elapseTimeSeconds;
double bytePerSecond = (x - fileViewer.uploadFileStartPtr) / elapseTimeSeconds;
double secondsLeft = Math.Round((fileViewer.uploadFileSize - x) / bytePerSecond);
mainLabel2.Text = bytePerSecondToString(bytePerSecond) + ", " + secondsLeftToString(secondsLeft);
}
progressBar2.Maximum = fileViewer.uploadFileArray.Count;
x = (int)(int)fileViewer.uploadFileSize;
x = (int)fileViewer.uploadFileArrayPtr;
if (x < 0) { x = 0; }
if (x > (int)fileViewer.uploadFileArray.Count) { x = fileViewer.uploadFileArray.Count; }
progressBar2.Value = fileViewer.uploadFileArrayPtr;
@@ -116,7 +116,7 @@ namespace MeshCentralRouter
}
progressBar2.Maximum = fileViewer.downloadFileArray.Count;
x = (int)(int)fileViewer.downloadFileSize;
x = (int)fileViewer.downloadFileArrayPtr;
if (x < 0) { x = 0; }
if (x > (int)fileViewer.downloadFileArray.Count) { x = fileViewer.downloadFileArray.Count; }
progressBar2.Value = fileViewer.downloadFileArrayPtr;

View File

@@ -61,6 +61,7 @@ namespace MeshCentralRouter
public string uploadRemotePath;
public FileStream uploadFileStream = null;
public long uploadFilePtr = 0;
public long uploadFileStartPtr = 0;
public long uploadFileSize = 0;
public DateTime uploadFileStartTime = DateTime.MinValue;
public string uploadFileName = null;
@@ -569,6 +570,7 @@ namespace MeshCentralRouter
{
// Clean up current upload
uploadFilePtr = 0;
uploadFileStartPtr = 0;
uploadFileSize = 0;
if (uploadFileStream != null) { uploadFileStream.Close(); uploadFileStream = null; }
@@ -593,6 +595,7 @@ namespace MeshCentralRouter
uploadLocalPath = null;
uploadRemotePath = null;
uploadFilePtr = 0;
uploadFileStartPtr = 0;
uploadFileSize = 0;
uploadFileName = null;
closeTransferDialog();
@@ -664,6 +667,7 @@ namespace MeshCentralRouter
uploadLocalPath = null;
uploadRemotePath = null;
uploadFilePtr = 0;
uploadFileStartPtr = 0;
uploadFileSize = 0;
uploadFileName = null;
closeTransferDialog();
@@ -674,7 +678,7 @@ namespace MeshCentralRouter
{
// Files are not the same length, append the rest
uploadFileStream.Seek(remoteFileSize, SeekOrigin.Begin);
uploadFilePtr = remoteFileSize;
uploadFilePtr = uploadFileStartPtr = remoteFileSize;
// Send UPLOAD command with append turned on
string cmd = "{\"action\":\"upload\",\"reqid\":" + (uploadFileArrayPtr + 1000) + ",\"path\":\"" + uploadRemotePath + "\",\"name\":\"" + name + "\",\"size\":" + uploadFileSize + ",\"append\":true}";
@@ -861,6 +865,7 @@ namespace MeshCentralRouter
uploadLocalPath = null;
uploadRemotePath = null;
uploadFilePtr = 0;
uploadFileStartPtr = 0;
uploadFileSize = 0;
if (uploadFileStream != null) { uploadFileStream.Close(); uploadFileStream = null; }
@@ -1269,6 +1274,7 @@ namespace MeshCentralRouter
uploadLocalPath = null;
uploadRemotePath = null;
uploadFilePtr = 0;
uploadFileStartPtr = 0;
uploadFileSize = 0;
uploadFileName = null;
closeTransferDialog();
@@ -1278,6 +1284,7 @@ namespace MeshCentralRouter
}
uploadFileSize = new FileInfo(localFilePath).Length;
uploadFilePtr = 0;
uploadFileStartPtr = 0;
uploadFileStartTime = DateTime.Now;
uploadFileName = localFileName;
@@ -1316,6 +1323,7 @@ namespace MeshCentralRouter
uploadLocalPath = null;
uploadRemotePath = null;
uploadFilePtr = 0;
uploadFileStartPtr = 0;
uploadFileSize = 0;
if (uploadFileStream != null) { uploadFileStream.Close(); uploadFileStream = null; }
closeTransferDialog();