mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Safer ContentManager::downloadDisappeared()
This commit is contained in:
parent
8e4e394f99
commit
2a1d53f0b0
@ -467,7 +467,15 @@ void ContentManager::removeDownload(QString bookId)
|
|||||||
void ContentManager::downloadDisappeared(QString bookId)
|
void ContentManager::downloadDisappeared(QString bookId)
|
||||||
{
|
{
|
||||||
removeDownload(bookId);
|
removeDownload(bookId);
|
||||||
kiwix::Book bCopy(mp_library->getBookById(bookId));
|
kiwix::Book bCopy;
|
||||||
|
try {
|
||||||
|
bCopy = mp_library->getBookById(bookId);
|
||||||
|
} catch ( const std::out_of_range& ) {
|
||||||
|
// If the download has disappeared as a result of some
|
||||||
|
// obscure chain of events, the book may have disappeared too.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bCopy.setDownloadId("");
|
bCopy.setDownloadId("");
|
||||||
mp_library->getKiwixLibrary()->addOrUpdateBook(bCopy);
|
mp_library->getKiwixLibrary()->addOrUpdateBook(bCopy);
|
||||||
mp_library->save();
|
mp_library->save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user