mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 04:54:29 -04:00
Format code using clang-format
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
#include "covercontroller_v2.h"
|
||||
#include "db_helper.h" //get libraries
|
||||
#include "db_helper.h" //get libraries
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_http_session.h"
|
||||
|
||||
@ -8,29 +8,26 @@
|
||||
|
||||
CoverControllerV2::CoverControllerV2() {}
|
||||
|
||||
void CoverControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
void CoverControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
response.setHeader("Content-Type", "image/jpeg");
|
||||
response.setHeader("Content-Type", "image/jpeg");
|
||||
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
QStringList pathElements = path.split('/');
|
||||
QString libraryName = DBHelper::getLibraryName(pathElements.at(3).toInt());
|
||||
QString fileName = pathElements.at(5);
|
||||
|
||||
QImage img(libraries.getPath(libraryName)+"/.yacreaderlibrary/covers/"+fileName);
|
||||
if (!img.isNull()) {
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
QImage img(libraries.getPath(libraryName) + "/.yacreaderlibrary/covers/" + fileName);
|
||||
if (!img.isNull()) {
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
img.save(&buffer, "JPG");
|
||||
response.write(ba,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
}
|
||||
response.write(ba, true);
|
||||
} else {
|
||||
response.setStatus(404, "not found");
|
||||
response.write("404 not found", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user