diff --git a/resources/i18n/en.json b/resources/i18n/en.json
index e8d67be..7ebadf2 100644
--- a/resources/i18n/en.json
+++ b/resources/i18n/en.json
@@ -146,6 +146,8 @@
"delete-book-text": "Are you sure you want to delete {{ZIM}}?",
"download-storage-error": "Storage Error",
"download-storage-error-text": "The system doesn't have enough storage available.",
+ "download-dir-missing": "Download directory doesn't exist.",
+ "download-dir-not-writable": "Download directory is not writable.",
"download-unavailable": "Download Unavailable",
"download-unavailable-text": "This download is unavailable.",
"open-book": "Open book",
diff --git a/resources/i18n/qqq.json b/resources/i18n/qqq.json
index 922511d..ba5c300 100644
--- a/resources/i18n/qqq.json
+++ b/resources/i18n/qqq.json
@@ -39,9 +39,11 @@
"videos": "{{identical|Video}}",
"yes": "{{identical|yes}}",
"no": "{{identical|no}}",
+ "download-dir-missing": "Error text displayed when it turns out that the download directory doesn't exist.",
+ "download-dir-not-writable": "Error text displayed when files cannot be created/saved in the download directory due to permissions",
"add-bookmark": "Represents the action of adding a page as a bookmark",
"remove-bookmark": "Represents the action of removing a page from the bookmarks",
- "open-link-in-web-browser": "Ouvrir le lien dans le navigateur",
+ "open-link-in-web-browser": "Hint for the action of opening the link in a web browser",
"download-dir-dialog-msg": "Please note that {{DIRECTORY}} should be placed on a newline.",
"monitor-dir-dialog-title": "\"Monitor\" means \"watch\" in this context. The monitor directory is monitored/watched for new ZIM files.",
"monitor-dir-dialog-msg": "\"Monitor\" means \"watch\" in this context. The monitor directory is monitored/watched for new ZIM files.",
diff --git a/src/contentmanager.cpp b/src/contentmanager.cpp
index 48f3677..313f873 100644
--- a/src/contentmanager.cpp
+++ b/src/contentmanager.cpp
@@ -53,8 +53,21 @@ void throwDownloadUnavailableError()
gt("download-unavailable-text"));
}
-void checkEnoughStorageAvailable(const kiwix::Book& book, QString targetDir)
+void checkThatBookCanBeSaved(const kiwix::Book& book, QString targetDir)
{
+ const QFileInfo targetDirInfo(targetDir);
+ if ( !targetDirInfo.isDir() ) {
+ throw ContentManagerError(gt("download-storage-error"),
+ gt("download-dir-missing"));
+ }
+
+ // XXX: This may lie under Windows
+ // XXX: (see https://doc.qt.io/qt-5/qfile.html#platform-specific-issues)
+ if ( !targetDirInfo.isWritable() ) {
+ throw ContentManagerError(gt("download-storage-error"),
+ gt("download-dir-not-writable"));
+ }
+
QStorageInfo storage(targetDir);
auto bytesAvailable = storage.bytesAvailable();
if (bytesAvailable == -1 || book.getSize() > (unsigned long long) bytesAvailable) {
@@ -580,7 +593,7 @@ const kiwix::Book& ContentManager::getRemoteOrLocalBook(const QString &id)
std::string ContentManager::startDownload(const kiwix::Book& book)
{
auto downloadPath = getSettingsManager()->getDownloadDir();
- checkEnoughStorageAvailable(book, downloadPath);
+ checkThatBookCanBeSaved(book, downloadPath);
typedef std::vector> DownloadOptions;
@@ -600,6 +613,8 @@ void ContentManager::downloadBook(const QString &id)
std::string downloadId;
try {
downloadId = startDownload(book);
+ } catch (const ContentManagerError& ) {
+ throw;
} catch (std::exception& e) {
throwDownloadUnavailableError();
}
diff --git a/src/readinglistbar.cpp b/src/readinglistbar.cpp
index 0f91ef7..ff3d0dd 100644
--- a/src/readinglistbar.cpp
+++ b/src/readinglistbar.cpp
@@ -39,6 +39,9 @@ void ReadingListBar::setupList()
} catch (std::out_of_range& e) {
continue;
}
+ if ( !archive ) {
+ continue;
+ }
try {
auto illustration = archive->getIllustrationItem(48);
std::string content = illustration.getData();