mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 03:26:05 -04:00
Merge pull request #174 from kiwix/download-dialog
add alert if there is not enough storage to download
This commit is contained in:
commit
f47d8f2243
@ -78,6 +78,10 @@ function init() {
|
||||
contentManager.downloadBook(book.id, function(did) {
|
||||
if (did.length == 0)
|
||||
return;
|
||||
if (did == "storage_error") {
|
||||
alert("not enough storage available.");
|
||||
return;
|
||||
}
|
||||
book.downloadId = did;
|
||||
downloadUpdaters[book.id] = setInterval(function() { getDownloadInfo(book.id); }, 1000);
|
||||
});
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <QUrlQuery>
|
||||
#include <QUrl>
|
||||
#include <QDir>
|
||||
#include <QStorageInfo>
|
||||
|
||||
ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader, QObject *parent)
|
||||
: QObject(parent),
|
||||
@ -181,6 +182,10 @@ QString ContentManager::downloadBook(const QString &id)
|
||||
return mp_library->getBookById(id);
|
||||
}
|
||||
}();
|
||||
QStorageInfo storage(QString::fromStdString(getDataDirectory()));
|
||||
if (book.getSize() > storage.bytesAvailable()) {
|
||||
return "storage_error";
|
||||
}
|
||||
auto booksList = mp_library->getBookIds();
|
||||
for (auto b : booksList)
|
||||
if (b.toStdString() == book.getId())
|
||||
|
Loading…
x
Reference in New Issue
Block a user