Skip to content

Commit 502bd5f

Browse files
committed
Fixed more cases where a stopped job could restart immediately.
1 parent b77b063 commit 502bd5f

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

VidCoder/Services/ProcessingService.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,14 +2532,27 @@ private void OnEncodeCompleted(EncodeJobViewModel finishedJobViewModel, VCEncode
25322532
string stopMessage;
25332533
if (completeReason == EncodeCompleteReason.ManualStopSingle)
25342534
{
2535+
int newIndex = 0;
2536+
25352537
// If we're stopping just this job, we need to push it down the queue and start up the next job in line
25362538
this.EncodeQueue.Edit(encodeQueueInnerList =>
25372539
{
25382540
encodeQueueInnerList.Remove(finishedJobViewModel);
2539-
encodeQueueInnerList.Insert(Math.Min(Config.MaxSimultaneousEncodes, encodeQueueInnerList.Count - 1), finishedJobViewModel);
2541+
2542+
newIndex = Math.Min(Config.MaxSimultaneousEncodes, encodeQueueInnerList.Count);
2543+
encodeQueueInnerList.Insert(newIndex, finishedJobViewModel);
25402544
});
25412545

2542-
this.EncodeNextJobs();
2546+
// If the stopped job was moved down the list and would no longer be restarted, we need to try to start the next jobs in the queue.
2547+
if (newIndex >= Config.MaxSimultaneousEncodes)
2548+
{
2549+
this.EncodeNextJobs();
2550+
}
2551+
else
2552+
{
2553+
// Rebuild the encoding jobs list to reflect that a job has stopped.
2554+
this.RebuildEncodingJobsList();
2555+
}
25432556

25442557
stopMessage = "Encoding stopped for " + finalOutputPath;
25452558
}

0 commit comments

Comments
 (0)