shared SandBoxedProcessor: Return SaveFileResult, remove defines

Not entirely ideal as SandboxedProcessor does not save anything,
but an improvement nevertheless over the current mess
Este commit está contenido en:
Albert S. 2022-06-24 17:10:43 +02:00
padre cf0c940b15
commit b6b3e2f3c0
Se han modificado 5 ficheros con 9 adiciones y 11 borrados

Ver fichero

@ -98,7 +98,7 @@ int main(int argc, char *argv[])
QString file = args.at(1);
SandboxedProcessor processor(file);
return processor.process();
return static_cast<int>(processor.process());
}
Command *cmd = commandFromName(commandName, dbService);
if(cmd != nullptr)

Ver fichero

@ -114,7 +114,7 @@ int main(int argc, char *argv[])
QString file = args.at(2);
SandboxedProcessor processor(file);
return processor.process();
return static_cast<int>(processor.process());
}
}
QString ipcSocketPath = Common::ipcSocketPath();

Ver fichero

@ -10,9 +10,6 @@ enum DataSource
ARRAY
};
#define NOTHING_PROCESSED 4
#define NO_ACCESS 5
class Processor
{
public:

Ver fichero

@ -80,7 +80,7 @@ void SandboxedProcessor::printResults(const QVector<PageData> &pageData)
fsstdout.close();
}
int SandboxedProcessor::process()
SaveFileResult SandboxedProcessor::process()
{
QFileInfo fileInfo(this->filePath);
Processor *processor = processors.value(fileInfo.suffix(), nullptr);
@ -94,12 +94,12 @@ int SandboxedProcessor::process()
}
if(!fileInfo.isReadable())
{
return NO_ACCESS;
return NOACCESS;
}
if(processor == nullptr || processor == nothingProcessor)
{
/* Nothing to do */
return NOTHING_PROCESSED;
return OK;
}
QVector<PageData> pageData;
@ -123,9 +123,9 @@ int SandboxedProcessor::process()
catch(LooqsGeneralException &e)
{
Logger::error() << "SandboxedProcessor: Error while processing" << absPath << ":" << e.message << Qt::endl;
return 3 /* PROCESSFAIL */;
return PROCESSFAIL;
}
printResults(pageData);
return 0;
return pageData.isEmpty() ? OK_WASEMPTY : OK;
}

Ver fichero

@ -3,6 +3,7 @@
#include <QString>
#include <QMimeDatabase>
#include "pagedata.h"
#include "savefileresult.h"
class SandboxedProcessor
{
@ -19,7 +20,7 @@ class SandboxedProcessor
this->filePath = filepath;
}
int process();
SaveFileResult process();
};
#endif // SANDBOXEDPROCESSOR_H