diff --git a/FrontSocket/FrontendServices.cs b/FrontSocket/FrontendServices.cs index b1bb2b9d..6a30b443 100644 --- a/FrontSocket/FrontendServices.cs +++ b/FrontSocket/FrontendServices.cs @@ -176,7 +176,7 @@ namespace Swarmops.Frontend.Socket process.WaitForExit(); - if (process.ExitCode != 0) + if (process.ExitCode == 2) { // Bad PDF file failCount++; @@ -190,9 +190,12 @@ namespace Swarmops.Frontend.Socket using (StreamReader pageCountReader = new StreamReader(pageCountFileName)) { - string pageCountString = pageCountReader.ReadToEnd().Trim(); - debugWriter.WriteLine("{0:D2}%, page count is '{1}'", progress, pageCountString); - currentFilePageCount = Int32.Parse(pageCountString); + string line = pageCountReader.ReadLine().Trim(); + while (line.StartsWith("WARNING") || line.StartsWith("qpdf:")) + { + line = pageCountReader.ReadLine().Trim(); // ignore warnings and chatter + } + currentFilePageCount = Int32.Parse(line); debugWriter.WriteLine("{0:D2}%, parsed to int as {1}", progress, currentFilePageCount); currentFilePageStepMilli = progressFileStep * 1000 / currentFilePageCount; } diff --git a/Site/Automation/UploadFileHandler.ashx b/Site/Automation/UploadFileHandler.ashx index 3fc01158..e9e65278 100644 --- a/Site/Automation/UploadFileHandler.ashx +++ b/Site/Automation/UploadFileHandler.ashx @@ -283,7 +283,7 @@ namespace Swarmops.Frontend.Automation process.WaitForExit(); int pdfPageCount = 0; - if (process.ExitCode != 0) + if (process.ExitCode == 2) // error code for qpdf { // Bad PDF file FilesStatus errorStatus = new FilesStatus(fullName, -1); //file.ContentLength); @@ -301,10 +301,15 @@ namespace Swarmops.Frontend.Automation using (StreamReader pageCountReader = new StreamReader(pageCountFileName)) { - string pageCountString = pageCountReader.ReadToEnd().Trim(); - pdfPageCount = Int32.Parse(pageCountString); + string line = pageCountReader.ReadLine().Trim(); + while (line.StartsWith("WARNING") || line.StartsWith("qpdf:")) + { + line = pageCountReader.ReadLine().Trim(); // ignore warnings and chatter + } + pdfPageCount = Int32.Parse(line); } + File.Delete(pageCountFileName); if (pdfPageCount < 10)