HaveAGitGat/Tdarr_Plugins

[BUG] Flow plugin Reorder streams always reorder even if not needed

Marnalas opened this issue · 2 comments

Hi there,

First of all, thank you for the excellent work !

I've noticed a bug with the flow plugin Reorder streams. It always reorder even if the existing order is correct. After some digging in the code, I saw this :

  1. Line 114 : the current state of the streams is stored
    const originalStreams = JSON.stringify(streams);
  2. Line 116 to 119 : all the streams are added a new property with their index
    streams.forEach((stream, index) => { // eslint-disable-next-line no-param-reassign stream.typeIndex = index; });
  3. Line 219 : after the new order of the streams have determined, the new state of the streams is compared to the original one. If any of the streams' properties has changed, then the ffmpeg command is set to operate the reorder.
    if (JSON.stringify(streams) !== originalStreams)

The problem is the step 2 always changes the streams (by adding a new property) so the comparison at step 3 always detects a change in the streams. I'll create a pull request with a solution to this problem.

Hi thanks :) added comment on your PR.

Was fixed in PR.