mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Extracted checkEnoughStorageAvailable()
... mainly for readability.
This commit is contained in:
parent
7ec85ac2fb
commit
852fa7cdb7
@ -47,10 +47,14 @@ void throwDownloadUnavailableError()
|
|||||||
gt("download-unavailable-text"));
|
gt("download-unavailable-text"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void throwStorageError()
|
void checkEnoughStorageAvailable(const kiwix::Book& book, QString targetDir)
|
||||||
{
|
{
|
||||||
|
QStorageInfo storage(targetDir);
|
||||||
|
auto bytesAvailable = storage.bytesAvailable();
|
||||||
|
if (bytesAvailable == -1 || book.getSize() > (unsigned long long) bytesAvailable) {
|
||||||
throw ContentManagerError(gt("download-storage-error"),
|
throw ContentManagerError(gt("download-storage-error"),
|
||||||
gt("download-storage-error-text"));
|
gt("download-storage-error-text"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opens the directory containing the input file path.
|
// Opens the directory containing the input file path.
|
||||||
@ -502,11 +506,7 @@ void ContentManager::downloadBook(const QString &id)
|
|||||||
|
|
||||||
const auto& book = getRemoteOrLocalBook(id);
|
const auto& book = getRemoteOrLocalBook(id);
|
||||||
auto downloadPath = KiwixApp::instance()->getSettingsManager()->getDownloadDir();
|
auto downloadPath = KiwixApp::instance()->getSettingsManager()->getDownloadDir();
|
||||||
QStorageInfo storage(downloadPath);
|
checkEnoughStorageAvailable(book, downloadPath);
|
||||||
auto bytesAvailable = storage.bytesAvailable();
|
|
||||||
if (bytesAvailable == -1 || book.getSize() > (unsigned long long) bytesAvailable) {
|
|
||||||
throwStorageError();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto booksList = mp_library->getBookIds();
|
auto booksList = mp_library->getBookIds();
|
||||||
for (auto b : booksList) {
|
for (auto b : booksList) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user