shared SandBoxedProcessor: Return SaveFileResult, remove defines
Not entirely ideal as SandboxedProcessor does not save anything, but an improvement nevertheless over the current mess
This commit is contained in:
parent
cf0c940b15
commit
b6b3e2f3c0
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -10,9 +10,6 @@ enum DataSource
|
||||
ARRAY
|
||||
};
|
||||
|
||||
#define NOTHING_PROCESSED 4
|
||||
#define NO_ACCESS 5
|
||||
|
||||
class Processor
|
||||
{
|
||||
public:
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Caricamento…
Fai riferimento in un nuovo problema
Block a user