From f4803eb351be66cf03431bbfa28cc990263bf103 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 1 Oct 2017 20:54:32 +0200 Subject: [PATCH] Logic fixes in off-by-one errors --- FrontSocket/FrontendServices.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/FrontSocket/FrontendServices.cs b/FrontSocket/FrontendServices.cs index b8b972a4..b1bb2b9d 100644 --- a/FrontSocket/FrontendServices.cs +++ b/FrontSocket/FrontendServices.cs @@ -234,7 +234,6 @@ namespace Swarmops.Frontend.Socket if (!process.HasExited) { process.WaitForExit(250); - // this is a more elaborate version of thread.sleep that prevents Apache recycling } if (pageCounter == 0) @@ -257,10 +256,6 @@ namespace Swarmops.Frontend.Socket } } - pageCounter++; - testPageFileName = String.Format("{0}-{1:D4}.png", relativeFileName, pageCounter); - debugWriter.WriteLine("{0:D2}%, testPageFileName set to {1}", progress, testPageFileName); - progress = progressFileStep * fileIndex + progressFileStep / 2 + currentFilePageStepMilli * (pageCounter + 1) / 2000; if (progress != lastProgress) { @@ -287,12 +282,18 @@ namespace Swarmops.Frontend.Socket // Increase the page counter and the file we're looking for + pageCounter++; + testPageFileName = String.Format("{0}-{1:D4}.png", relativeFileName, pageCounter); + debugWriter.WriteLine("{0:D2}%, testPageFileName set to {1}", progress, testPageFileName); } - // We've seen the last page being written -- wait for process to exit + // We've seen the last page being written -- wait for process to exit to assure it's complete debugWriter.WriteLine("{0:D2}%, waiting for process exit", progress); - process.WaitForExit(); + if (!process.HasExited) + { + process.WaitForExit(); + } // Save the last page