mirror of https://github.com/kiwix/libkiwix.git
Do not automatically update the status of existing Download.
User may already have a pointer to the `Download` and it is not protected against concurrent access. We could update the status of new created `Download` as by definition, no one have a pointer on it. But it better to not do it neither : - For consistency - Because the first call on update status may be long on windows (because of file preallocation). It is better to not block the downloader for that.
This commit is contained in:
parent
1aa8521e15
commit
d1fe1b89ae
|
@ -180,23 +180,20 @@ Download* Downloader::startDownload(const std::string& uri, const std::vector<st
|
|||
Download* Downloader::getDownload(const std::string& did)
|
||||
{
|
||||
try {
|
||||
m_knownDownloads.at(did).get()->updateStatus(true);
|
||||
return m_knownDownloads.at(did).get();
|
||||
} catch(std::exception& e) {
|
||||
for (auto gid : mp_aria->tellActive()) {
|
||||
if (gid == did) {
|
||||
m_knownDownloads[gid] = std::unique_ptr<Download>(new Download(mp_aria, gid));
|
||||
m_knownDownloads.at(gid).get()->updateStatus(true);
|
||||
return m_knownDownloads[gid].get();
|
||||
}
|
||||
}
|
||||
for (auto gid : mp_aria->tellWaiting()) {
|
||||
if (gid == did) {
|
||||
m_knownDownloads[gid] = std::unique_ptr<Download>(new Download(mp_aria, gid));
|
||||
m_knownDownloads.at(gid).get()->updateStatus(true);
|
||||
return m_knownDownloads[gid].get();
|
||||
}
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue