Skip to content

Commit

Permalink
Merge pull request #669 from HaveAGitGat/live_size
Browse files Browse the repository at this point in the history
Add error variable
  • Loading branch information
HaveAGitGat authored Jun 18, 2024
2 parents 3ab3707 + 4ac329f commit 87ab148
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.plugin = exports.details = void 0;
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
var details = function () { return ({
name: 'Compare File Size Ratio Live',
description: "\n Compare either the estimated final size or current output size to the input size and \n give an error if estimated final size or current size surpasses the threshold %.\n\n Works with 'FfmpegCommand', 'HandBrake Custom Arguments', 'Run Classic Transcode' and other flow plugins \n that output a file.\n\n Can be placed anywhere before a plugin which outputs a new file.\n ',\n ",
description: "\n Compare either the estimated final size or current output size to the input size and \n give an error if estimated final size or current size surpasses the threshold %.\n\n Works with 'FfmpegCommand', 'HandBrake Custom Arguments', 'Run Classic Transcode' and other flow plugins \n that output a file.\n\n Can be placed anywhere before a plugin which outputs a new file.\n\n You can check if this plugin caused an error by using 'Check Flow Variable' and checking if \n {{{args.variables.liveSizeCompare.error}}} is true.\n ',\n ",
style: {
borderColor: 'orange',
},
Expand Down Expand Up @@ -128,6 +128,7 @@ var plugin = function (args) {
compareMethod: compareMethod,
thresholdPerc: thresholdPerc,
checkDelaySeconds: checkDelaySeconds,
error: false,
};
return {
outputFileObj: args.inputFileObj,
Expand Down
2 changes: 2 additions & 0 deletions FlowPlugins/FlowHelpers/1.0.0/cliUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ var CLI = /** @class */ (function () {
_this.config.jobLog("Ratio: ".concat(ratio, "%"));
_this.config.jobLog("Ratio is greater than threshold: ".concat(thresholdPerc_1, "%, cancelling job"));
_this.cancelled = true;
// @ts-expect-error must exist to be here
_this.config.args.variables.liveSizeCompare.error = true;
_this.killThread();
};
if (compareMethod === 'estimatedFinalSize'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const details = (): IpluginDetails => ({
that output a file.
Can be placed anywhere before a plugin which outputs a new file.
You can check if this plugin caused an error by using 'Check Flow Variable' and checking if
{{{args.variables.liveSizeCompare.error}}} is true.
',
`,
style: {
Expand Down Expand Up @@ -155,6 +158,7 @@ const plugin = (args: IpluginInputArgs):IpluginOutputArgs => {
compareMethod,
thresholdPerc,
checkDelaySeconds,
error: false,
};

return {
Expand Down
2 changes: 2 additions & 0 deletions FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ class CLI {

this.config.jobLog(`Ratio is greater than threshold: ${thresholdPerc}%, cancelling job`);
this.cancelled = true;
// @ts-expect-error must exist to be here
this.config.args.variables.liveSizeCompare.error = true;
this.killThread();
};

Expand Down
1 change: 1 addition & 0 deletions FlowPluginsTs/FlowHelpers/1.0.0/interfaces/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export interface IliveSizeCompare {
compareMethod: string,
thresholdPerc: number,
checkDelaySeconds: number,
error: boolean,
}

export interface Ivariables {
Expand Down

0 comments on commit 87ab148

Please sign in to comment.