From aa941e943c2e3dd9907ee664431708ae93c29566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Wed, 8 Aug 2018 22:09:51 +0300 Subject: [PATCH] libcore|FS: Fixed loading of a remote file repository index --- .../core/src/filesys/remote/webhostedlink.cpp | 37 ++++++++----------- .../libs/doomsday/src/filesys/idgameslink.cpp | 4 +- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/doomsday/libs/core/src/filesys/remote/webhostedlink.cpp b/doomsday/libs/core/src/filesys/remote/webhostedlink.cpp index d47e19b32d..690b6e1160 100644 --- a/doomsday/libs/core/src/filesys/remote/webhostedlink.cpp +++ b/doomsday/libs/core/src/filesys/remote/webhostedlink.cpp @@ -87,7 +87,7 @@ DE_PIMPL(WebHostedLink) }); } - void receiveFileContents(QueryId id, WebRequest &web) + void receiveFileContentStream(QueryId id, WebRequest &web) { if (web.isFailed()) { @@ -95,25 +95,20 @@ DE_PIMPL(WebHostedLink) /// @todo Abort query with error. return; } -// if (web.isPending()) -// { -// return; -// } -// if (web.isSucceeded()) -// { - //qDebug() << "Content-Length:" << reply->header(QNetworkRequest::ContentLengthHeader); - const dsize contentLength = web.contentLength(); //reply->header(QNetworkRequest::ContentLengthHeader).toULongLong(); - //qDebug() << "pos:" << pos << contentLength << reply->url(); + // Total length of the content. + const dsize contentLength = web.contentLength(); - // Ths is the complete downloaded file. - // QByteArray const data = reply->readAll(); - const Block data = web.readAll(); + const Query *query = self().findQuery(id); + const Block chunk = web.readAll(); + debug("pos: %zu clen: %zu chunk: %zu [q%llu]", + query->receivedBytes, + contentLength, + chunk.size(), + id); - Query const *query = self().findQuery(id); - self().chunkReceived(id, query->receivedBytes, data, - contentLength ? contentLength : dsize(data.size())); - // } + self().chunkReceived( + id, query->receivedBytes, chunk, contentLength ? contentLength : dsize(chunk.size())); } }; @@ -139,7 +134,6 @@ WebHostedLink::WebHostedLink(String const &address, String const &indexPath) }; req->get(address / indexPath); - // QNetworkReply *reply = filesys::RemoteFeedRelay::get().network().get(req); // QObject::connect(reply, &QNetworkReply::finished, [this, reply] () // { @@ -202,10 +196,11 @@ void WebHostedLink::transmit(Query const &query) d->pendingRequests.insert(web); const auto id = query.id; - web->audienceForProgress() += [this, id, web]() { - d->receiveFileContents(id, *web); + web->audienceForReadyRead() += [this, id, web]() { + d->receiveFileContentStream(id, *web); }; - web->audienceForFinished() += [this, web]() { + web->audienceForFinished() += [this, id, web]() { + d->receiveFileContentStream(id, *web); d->pendingRequests.remove(web); trash(web); }; diff --git a/doomsday/libs/doomsday/src/filesys/idgameslink.cpp b/doomsday/libs/doomsday/src/filesys/idgameslink.cpp index fba141ff31..635a186b3a 100644 --- a/doomsday/libs/doomsday/src/filesys/idgameslink.cpp +++ b/doomsday/libs/doomsday/src/filesys/idgameslink.cpp @@ -163,8 +163,8 @@ void IdgamesLink::parseRepositoryIndex(const Block &data) const RegExp reDir("^\\.?(.*):$"); const RegExp reTotal("^total\\s+\\d+$"); const RegExp reFile("^(-|d)[-rwxs]+\\s+\\d+\\s+\\w+\\s+\\w+\\s+" - "(\\d+)\\s+(\\w+\\s+\\d+\\s+[0-9:]+)\\s+(.*)$", - CaseInsensitive); + "(\\d+)\\s+(\\w+\\s+\\d+\\s+[0-9:]+)\\s+(.*)$", + CaseInsensitive); String currentPath; bool ignore = false; const RegExp reIncludedPaths("^/(levels|music|sounds|themes)");