Skip to content

Commit

Permalink
Prevent crashes with uninitalised progress bars
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpainter committed Oct 4, 2020
1 parent 4f8e405 commit 25f1b21
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
9 changes: 9 additions & 0 deletions Sanchez.Workflow/Steps/Equirectangular/Stitch/ShouldWrite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ public override ExecutionResult Run(IStepExecutionContext context)

internal static class ShouldWriteExtensions
{
internal static IStepBuilder<TData, ShouldWrite> ShouldWrite<TData>(this IWorkflowBuilder<TData> builder, DateTime? timestamp)
where TData : WorkflowData
=> builder
.StartWith<ShouldWrite, TData>()
.WithActivity()
.WithProgressBar()
.Input(step => step.Timestamp, data => timestamp)
.Output(data => data.AlreadyRenderedCount, step => step.AlreadyRenderedCount);

internal static IStepBuilder<TData, ShouldWrite> ShouldWrite<TStep, TData>(this IStepBuilder<TData, TStep> builder, DateTime? timestamp)
where TStep : IStepBody
where TData : WorkflowData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public void Build(IWorkflowBuilder<EquirectangularStitchWorkflowData> builder)
.InitialiseSatelliteRegistry()
.GetSourceRegistrations()
.CreateActivity()
.InitialiseProgressBar(data => data.Activity!.Registrations.Count + 1)
.If(data => data.Activity!.Registrations.Any())
.Do(branch => branch
.InitialiseProgressBar(data => data.Activity!.Registrations.Count + 1)
.ShouldWrite(_options.Timestamp)
.Branch(true, builder
.CreateBranch()
Expand Down
28 changes: 16 additions & 12 deletions Sanchez.Workflow/Workflows/Geostationary/GeostationaryWorkflow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using JetBrains.Annotations;
using System.Linq;
using JetBrains.Annotations;
using Sanchez.Workflow.Models;
using Sanchez.Workflow.Steps.Common;
using Sanchez.Workflow.Steps.Geostationary;
Expand All @@ -17,17 +18,20 @@ public void Build(IWorkflowBuilder<GeostationaryWorkflowData> builder)
.GetSourceRegistrations()
.CreateActivity()
.InitialiseProgressBar(data => data.Activity!.Registrations.Count + 1)
.ForEach(data => data.Activity!.Registrations, _ => false)
.Do(registration => registration
.SetWorkflowRegistration()
.ShouldWriteSingle()
.Branch(true, builder.CreateBranch()
.LoadImageSingle()
.NormaliseImage()
.RenderUnderlay()
.ColourCorrect()
.ApplyHaze()
.SaveImage()
.If(data => data.Activity!.Registrations.Any())
.Do(branch => branch
.ForEach(data => data.Activity!.Registrations, _ => false)
.Do(registration => registration
.SetWorkflowRegistration()
.ShouldWriteSingle()
.Branch(true, builder.CreateBranch()
.LoadImageSingle()
.NormaliseImage()
.RenderUnderlay()
.ColourCorrect()
.ApplyHaze()
.SaveImage()
)
)
)
.LogCompletion();
Expand Down

0 comments on commit 25f1b21

Please sign in to comment.