mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-23 12:07:00 -04:00
Fix urlschemehandle to adapt to new kiwix-lib.
New kiwix-lib forbid to create a "empty" `kiwix::Entry`.
This commit is contained in:
parent
bd54ad9d79
commit
f240ea78a1
@ -30,35 +30,25 @@ UrlSchemeHandler::handleContentRequest(QWebEngineUrlRequestJob *request)
|
|||||||
request->fail(QWebEngineUrlRequestJob::UrlNotFound);
|
request->fail(QWebEngineUrlRequestJob::UrlNotFound);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
kiwix::Entry entry;
|
|
||||||
try {
|
try {
|
||||||
entry = reader->getEntryFromPath(url);
|
kiwix::Entry entry = reader->getEntryFromPath(url);
|
||||||
} catch (kiwix::NoEntry&) {
|
if (entry.isRedirect()) {
|
||||||
url = "A/" + url;
|
|
||||||
try {
|
|
||||||
entry = reader->getEntryFromPath(url);
|
|
||||||
} catch (kiwix::NoEntry&) {
|
|
||||||
request->fail(QWebEngineUrlRequestJob::UrlNotFound);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (entry.isRedirect()) {
|
|
||||||
try {
|
|
||||||
entry = entry.getFinalEntry();
|
entry = entry.getFinalEntry();
|
||||||
} catch (kiwix::NoEntry&) {
|
auto path = QString("/") + QString::fromStdString(entry.getPath());
|
||||||
request->fail(QWebEngineUrlRequestJob::UrlNotFound);
|
qurl.setPath(path);
|
||||||
|
request->redirect(qurl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto path = QString("/") + QString::fromStdString(entry.getPath());
|
|
||||||
qurl.setPath(path);
|
BlobBuffer* buffer = new BlobBuffer(entry.getBlob());
|
||||||
request->redirect(qurl);
|
auto mimeType = QByteArray::fromStdString(entry.getMimetype());
|
||||||
return;
|
mimeType = mimeType.split(';')[0];
|
||||||
|
connect(request, &QObject::destroyed, buffer, &QObject::deleteLater);
|
||||||
|
request->reply(mimeType, buffer);
|
||||||
|
} catch (kiwix::NoEntry&) {
|
||||||
|
request->fail(QWebEngineUrlRequestJob::UrlNotFound);
|
||||||
}
|
}
|
||||||
BlobBuffer* buffer = new BlobBuffer(entry.getBlob());
|
|
||||||
auto mimeType = QByteArray::fromStdString(entry.getMimetype());
|
|
||||||
mimeType = mimeType.split(';')[0];
|
|
||||||
connect(request, &QObject::destroyed, buffer, &QObject::deleteLater);
|
|
||||||
request->reply(mimeType, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user