|
10 | 10 | var _uploadFormId; |
11 | 11 | var _uploadFormData; |
12 | 12 | var _pollingInterval = 250; // in ms |
| 13 | + var _slowerPollingInterval = 1000; // in ms |
13 | 14 | var _pingUrl; |
14 | | - var _failureCount; |
15 | 15 | var _isUploadInProgress; |
| 16 | + var _uploadStartTime; |
16 | 17 |
|
17 | 18 | this.init = function (pingUrl, formId, jQueryUrl, actionUrl, cancelUrl, submitVerifyUrl) { |
18 | 19 | _pingUrl = pingUrl; |
|
78 | 79 | if (InProgressPackage != null) { |
79 | 80 | bindData(InProgressPackage); |
80 | 81 | } |
81 | | - } |
| 82 | + }; |
82 | 83 |
|
83 | 84 | function resetFileSelectFeedback() { |
84 | 85 | $('#file-select-feedback').attr('value', 'Browse or Drop files to select a package...'); |
|
291 | 292 |
|
292 | 293 | function startProgressBar() { |
293 | 294 | _isUploadInProgress = true; |
294 | | - _failureCount = 0; |
| 295 | + _uploadStartTime = new Date(); |
295 | 296 |
|
296 | 297 | setProgressIndicator(0, ''); |
297 | 298 | $("#upload-progress-bar-container").removeClass("hidden"); |
|
301 | 302 | function endProgressBar() { |
302 | 303 | $("#upload-progress-bar-container").addClass("hidden"); |
303 | 304 | _isUploadInProgress = false; |
| 305 | + _uploadStartTime = null; |
304 | 306 | } |
305 | 307 |
|
306 | 308 | function getProgress() { |
|
334 | 336 | } |
335 | 337 |
|
336 | 338 | function onGetProgressError(result) { |
337 | | - if (++_failureCount < 3) { |
338 | | - setTimeout(getProgress, _pollingInterval); |
| 339 | + if (_uploadStartTime) { |
| 340 | + var currentTime = new Date(); |
| 341 | + var uploadDuration = currentTime - _uploadStartTime; |
| 342 | + |
| 343 | + // Continue polling as if no errors have occurred for the first 5 seconds of the upload. |
| 344 | + // After that, poll at a slower pace for 5 minutes. |
| 345 | + if (uploadDuration < 5 * 1000) { |
| 346 | + setTimeout(getProgress, _pollingInterval); |
| 347 | + } else if (uploadDuration < 5 * 60 * 1000) { |
| 348 | + setTimeout(getProgress, _slowerPollingInterval); |
| 349 | + } |
339 | 350 | } |
340 | 351 | } |
341 | 352 |
|
|
0 commit comments