Merge pull request #3460 from sbwalker/dev

improve upload time estimate calculations and limit polling attempts
This commit is contained in:
Shaun Walker 2023-11-07 15:14:13 -05:00 committed by GitHub
commit 12172168f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -377,14 +377,19 @@
{
success = false;
var filename = uploads[upload].Split(':')[0];
var size = Int64.Parse(uploads[upload].Split(':')[1]);
var maxattempts = (int)Math.Ceiling(size / 500000.0) + 4; // 30 MB takes 1 minute at 5 Mbps (min 5 attempts)
var size = Int64.Parse(uploads[upload].Split(':')[1]); // bytes
var megabits = (size / 1048576.0) * 8; // binary conversion
var uploadspeed = 2; // 2 Mbps (3G ranges from 300Kbps to 3Mbps)
var uploadtime = (megabits / uploadspeed); // seconds
var maxattempts = 5; // polling (minimum timeout duration will be 5 seconds)
var sleep = (int)Math.Ceiling(uploadtime / maxattempts) * 1000; // milliseconds
int attempts = 0;
while (attempts < maxattempts && !success)
{
attempts += 1;
Thread.Sleep(1000);
Thread.Sleep(sleep);
if (Folder == Constants.PackagesFolder)
{