Skip to content

Commit

Permalink
Scale error delay
Browse files Browse the repository at this point in the history
  • Loading branch information
pcprince committed Jun 15, 2022
1 parent 4510a37 commit 665a0b1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
16 changes: 15 additions & 1 deletion processing/uiDownsampling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -186,7 +199,8 @@ function downsampleFiles () {

}

ui.sleep(3000);
ui.sleep(sleepAmount);
sleepAmount = sleepAmount / 2;

}

Expand Down
16 changes: 15 additions & 1 deletion processing/uiExpansion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -283,7 +296,8 @@ function expandFiles () {

}

ui.sleep(3000);
ui.sleep(sleepAmount);
sleepAmount = sleepAmount / 2;

}

Expand Down
16 changes: 15 additions & 1 deletion processing/uiSplit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -188,7 +201,8 @@ function splitFiles () {

}

ui.sleep(3000);
ui.sleep(sleepAmount);
sleepAmount = sleepAmount / 2;

}

Expand Down

0 comments on commit 665a0b1

Please sign in to comment.