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
Esse commit está contido em:
Albert S. 2022-06-24 17:34:11 +02:00
commit 83ed935790
1 arquivos alterados com 9 adições e 11 exclusões

Ver arquivo

@ -98,7 +98,7 @@ SaveFileResult FileSaver::saveFile(const QFileInfo &fileInfo)
QVector<PageData> pageData; QVector<PageData> pageData;
QString canonicalPath = fileInfo.canonicalFilePath(); QString canonicalPath = fileInfo.canonicalFilePath();
int status = -1; int processorReturnCode = -1;
if(!fileInfo.isReadable()) if(!fileInfo.isReadable())
{ {
@ -143,21 +143,19 @@ SaveFileResult FileSaver::saveFile(const QFileInfo &fileInfo)
in >> pd; in >> pd;
pageData.append(pd); pageData.append(pd);
} }
status = process.exitCode(); processorReturnCode = process.exitCode();
if(status != OK) if(processorReturnCode != OK && processorReturnCode != OK_WASEMPTY)
{ {
Logger::error() << "FileSaver::saveFile(): Error while processing" << canonicalPath << ":" Logger::error() << "FileSaver::saveFile(): Error while processing" << canonicalPath << ":"
<< "Exit code " << status << Qt::endl; << "Exit code " << processorReturnCode << Qt::endl;
return static_cast<SaveFileResult>(status); return static_cast<SaveFileResult>(processorReturnCode);
} }
} }
SaveFileResult result = this->dbService->saveFile(fileInfo, pageData);
// Could happen if a file corrupted for example if(result == OK && processorReturnCode == OK_WASEMPTY)
if(pageData.isEmpty() && status != OK)
{ {
Logger::error() << "Could not get any content for " << canonicalPath << Qt::endl; return OK_WASEMPTY;
} }
return result;
return this->dbService->saveFile(fileInfo, pageData);
} }