diff --git a/Community/Tdarr_Plugin_a9he_New_file_size_check.js b/Community/Tdarr_Plugin_a9he_New_file_size_check.js index 2f446b0..9861a0e 100644 --- a/Community/Tdarr_Plugin_a9he_New_file_size_check.js +++ b/Community/Tdarr_Plugin_a9he_New_file_size_check.js @@ -57,11 +57,13 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { const sizeText = `New file has size ${newSize.toFixed(3)} MB which is ${ratio}% ` + `of original file size: ${oldSize.toFixed(3)} MB`; + const getBound = (bound) => (bound / 100) * oldSize; + const errText = 'New file size not within limits.'; - if (newSize > (inputs.upperBound / 100) * oldSize) { + if (newSize > getBound(inputs.upperBound)) { // Item will be errored in UI throw new Error(`${errText} ${sizeText}. upperBound is ${inputs.upperBound}%`); - } else if (newSize < (inputs.lowerBound / 100) * oldSize) { + } else if (newSize < getBound(inputs.lowerBound)) { // Item will be errored in UI throw new Error(`${errText} ${sizeText}. lowerBound is ${inputs.lowerBound}%`); } else {