Merge pull request #183 from kiwix/pause-book-download-before-cancel

Pause book's download while dialog to cancel is open
This commit is contained in:
Matthieu Gautier 2019-06-24 14:43:36 +02:00 committed by GitHub
commit 7b6d2003cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -100,10 +100,13 @@ function init() {
}
},
cancelBook : function(book) {
contentManager.pauseBook(book.id);
if (confirm("Are you sure you want to abort the download of '" + book.title + "' ?")) {
contentManager.cancelBook(book.id);
clearInterval(downloadUpdaters[book.id]);
Vue.delete(app.downloads, book.id);
} else {
contentManager.resumeBook(book.id);
}
},
displayedBooks : function(books, nb) {

View File

@ -237,7 +237,9 @@ void ContentManager::cancelBook(const QString& id)
{
auto& b = mp_library->getBookById(id);
auto download = mp_downloader->getDownload(b.getDownloadId());
download->cancelDownload();
if (download->getStatus() != kiwix::Download::K_COMPLETE) {
download->cancelDownload();
}
QString fileToRemove = QString::fromUtf8(getLastPathElement(download->getPath()).c_str()) + "*";
eraseBookFilesFromComputer(fileToRemove);
mp_library->removeBookFromLibraryById(id);