Skip to content

Commit

Permalink
libcore|FS: Fixed loading of a remote file repository index
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 56367b3 commit aa941e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
37 changes: 16 additions & 21 deletions doomsday/libs/core/src/filesys/remote/webhostedlink.cpp
Expand Up @@ -87,33 +87,28 @@ DE_PIMPL(WebHostedLink)
});
}

void receiveFileContents(QueryId id, WebRequest &web)
void receiveFileContentStream(QueryId id, WebRequest &web)
{
if (web.isFailed())
{
LOG_NET_WARNING(web.errorMessage());
/// @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()));
}
};

Expand All @@ -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] ()
// {
Expand Down Expand Up @@ -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);
};
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libs/doomsday/src/filesys/idgameslink.cpp
Expand Up @@ -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)");
Expand Down

0 comments on commit aa941e9

Please sign in to comment.