From 83ed9357904a4f585d096f551e0a4a2691dfa0a2 Mon Sep 17 00:00:00 2001 From: Albert S Date: Fri, 24 Jun 2022 17:34:11 +0200 Subject: [PATCH] shared: FileSaver: Return OK_WASEMPTY We get OK_WASEMPTY from the processor when there usually should be something. Rarely, this is not the case. Let the callers know about this state at least --- shared/filesaver.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/shared/filesaver.cpp b/shared/filesaver.cpp index 54fc2ed..be020e7 100644 --- a/shared/filesaver.cpp +++ b/shared/filesaver.cpp @@ -98,7 +98,7 @@ SaveFileResult FileSaver::saveFile(const QFileInfo &fileInfo) QVector pageData; QString canonicalPath = fileInfo.canonicalFilePath(); - int status = -1; + int processorReturnCode = -1; if(!fileInfo.isReadable()) { @@ -143,21 +143,19 @@ SaveFileResult FileSaver::saveFile(const QFileInfo &fileInfo) in >> pd; pageData.append(pd); } - status = process.exitCode(); - if(status != OK) + processorReturnCode = process.exitCode(); + if(processorReturnCode != OK && processorReturnCode != OK_WASEMPTY) { Logger::error() << "FileSaver::saveFile(): Error while processing" << canonicalPath << ":" - << "Exit code " << status << Qt::endl; + << "Exit code " << processorReturnCode << Qt::endl; - return static_cast(status); + return static_cast(processorReturnCode); } } - - // Could happen if a file corrupted for example - if(pageData.isEmpty() && status != OK) + SaveFileResult result = this->dbService->saveFile(fileInfo, pageData); + if(result == OK && processorReturnCode == OK_WASEMPTY) { - Logger::error() << "Could not get any content for " << canonicalPath << Qt::endl; + return OK_WASEMPTY; } - - return this->dbService->saveFile(fileInfo, pageData); + return result; }