From 665a0b151051de62d03b6a3f4b86bdf6ba41df34 Mon Sep 17 00:00:00 2001 From: Peter Prince Date: Wed, 15 Jun 2022 14:17:45 +0100 Subject: [PATCH] Scale error delay --- processing/uiDownsampling.js | 16 +++++++++++++++- processing/uiExpansion.js | 16 +++++++++++++++- processing/uiSplit.js | 16 +++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/processing/uiDownsampling.js b/processing/uiDownsampling.js index fbf263f..55a4744 100644 --- a/processing/uiDownsampling.js +++ b/processing/uiDownsampling.js @@ -44,6 +44,8 @@ const downsampleButton = document.getElementById('downsample-button'); var files = []; var downsampling = false; +const DEFAULT_SLEEP_AMOUNT = 3000; + /* Disable UI elements in main window while progress bar is open and downsample is in progress */ function disableUI () { @@ -106,6 +108,9 @@ function downsampleFiles () { let errorFilePath; + let sleepAmount = DEFAULT_SLEEP_AMOUNT; + let successesWithoutError = 0; + for (let i = 0; i < files.length; i++) { /* If progress bar is closed, the downsample task is considered cancelled. This will contact the main thread and ask if that has happened */ @@ -145,11 +150,19 @@ function downsampleFiles () { if (response.success) { successCount++; + successesWithoutError++; + + if (successesWithoutError >= 10) { + + sleepAmount = DEFAULT_SLEEP_AMOUNT; + + } } else { /* Add error to log file */ + successesWithoutError = 0; errorCount++; errors.push(response.error); errorFiles.push(files[i]); @@ -186,7 +199,8 @@ function downsampleFiles () { } - ui.sleep(3000); + ui.sleep(sleepAmount); + sleepAmount = sleepAmount / 2; } diff --git a/processing/uiExpansion.js b/processing/uiExpansion.js index eadf316..1a753d8 100644 --- a/processing/uiExpansion.js +++ b/processing/uiExpansion.js @@ -52,6 +52,8 @@ var expanding = false; var expansionType = 'DURATION'; +const DEFAULT_SLEEP_AMOUNT = 3000; + /* Disable UI elements in main window while progress bar is open and expansion is in progress */ function disableUI () { @@ -182,6 +184,9 @@ function expandFiles () { let maxLength = null; + let sleepAmount = DEFAULT_SLEEP_AMOUNT; + let successesWithoutError = 0; + for (let i = 0; i < files.length; i++) { /* If progress bar is closed, the expansion task is considered cancelled. This will contact the main thread and ask if that has happened */ @@ -242,11 +247,19 @@ function expandFiles () { if (response.success) { successCount++; + successesWithoutError++; + + if (successesWithoutError >= 10) { + + sleepAmount = DEFAULT_SLEEP_AMOUNT; + + } } else { /* Add error to log file */ + successesWithoutError = 0; errorCount++; errors.push(response.error); errorFiles.push(files[i]); @@ -283,7 +296,8 @@ function expandFiles () { } - ui.sleep(3000); + ui.sleep(sleepAmount); + sleepAmount = sleepAmount / 2; } diff --git a/processing/uiSplit.js b/processing/uiSplit.js index a011816..de17986 100644 --- a/processing/uiSplit.js +++ b/processing/uiSplit.js @@ -40,6 +40,8 @@ const splitButton = document.getElementById('split-button'); var files = []; var splitting = false; +const DEFAULT_SLEEP_AMOUNT = 3000; + /* Disable UI elements in main window while progress bar is open and split is in progress */ function disableUI () { @@ -108,6 +110,9 @@ function splitFiles () { let errorFilePath; + let sleepAmount = DEFAULT_SLEEP_AMOUNT; + let successesWithoutError = 0; + for (let i = 0; i < files.length; i++) { /* If progress bar is closed, the split task is considered cancelled. This will contact the main thread and ask if that has happened */ @@ -147,11 +152,19 @@ function splitFiles () { if (response.success) { successCount++; + successesWithoutError++; + + if (successesWithoutError >= 10) { + + sleepAmount = DEFAULT_SLEEP_AMOUNT; + + } } else { /* Add error to log file */ + successesWithoutError = 0; errorCount++; errors.push(response.error); errorFiles.push(files[i]); @@ -188,7 +201,8 @@ function splitFiles () { } - ui.sleep(3000); + ui.sleep(sleepAmount); + sleepAmount = sleepAmount / 2; }