mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-24 04:32:15 -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) {
|
contentManager.downloadBook(book.id, function(did) {
|
||||||
if (did.length == 0)
|
if (did.length == 0)
|
||||||
return;
|
return;
|
||||||
|
if (did == "storage_error") {
|
||||||
|
alert("not enough storage available.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
book.downloadId = did;
|
book.downloadId = did;
|
||||||
downloadUpdaters[book.id] = setInterval(function() { getDownloadInfo(book.id); }, 1000);
|
downloadUpdaters[book.id] = setInterval(function() { getDownloadInfo(book.id); }, 1000);
|
||||||
});
|
});
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QStorageInfo>
|
||||||
|
|
||||||
ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader, QObject *parent)
|
ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader, QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
@ -181,6 +182,10 @@ QString ContentManager::downloadBook(const QString &id)
|
|||||||
return mp_library->getBookById(id);
|
return mp_library->getBookById(id);
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
QStorageInfo storage(QString::fromStdString(getDataDirectory()));
|
||||||
|
if (book.getSize() > storage.bytesAvailable()) {
|
||||||
|
return "storage_error";
|
||||||
|
}
|
||||||
auto booksList = mp_library->getBookIds();
|
auto booksList = mp_library->getBookIds();
|
||||||
for (auto b : booksList)
|
for (auto b : booksList)
|
||||||
if (b.toStdString() == book.getId())
|
if (b.toStdString() == book.getId())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user