fix: download job stops all together even if 1 entry is failed to create directory (#510)

Also, when some entry failed to create download folder, it shows a notification saying only "invalid location: /downloads" which is misleading.

* more detail notification on invalid download location
* fix: download job stops all together even if 1 entry is failed to create directory
This commit is contained in:
Cuong-Tran 2024-12-31 11:07:43 +07:00 committed by GitHub
parent a66dd25eed
commit ec97db588a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -45,7 +45,8 @@ class DownloadProvider(
throw Exception(
context.stringResource(
MR.strings.invalid_location,
downloadsDir?.displayablePath ?: "",
(downloadsDir?.displayablePath ?: "") +
"/${getSourceDirName(source)}/${getMangaDirName(mangaTitle)}",
),
)
}

View file

@ -327,7 +327,15 @@ class Downloader(
* @param download the chapter to be downloaded.
*/
private suspend fun downloadChapter(download: Download) {
val mangaDir = provider.getMangaDir(/* SY --> */ download.manga.ogTitle /* SY <-- */, download.source)
val mangaDir: UniFile
try {
mangaDir = provider.getMangaDir(/* SY --> */ download.manga.ogTitle /* SY <-- */, download.source)
} catch (error: Exception) {
logcat(LogPriority.ERROR, error)
download.status = Download.State.ERROR
notifier.onError(error.message, download.chapter.name, download.manga.title, download.manga.id)
return
}
val availSpace = DiskUtil.getAvailableStorageSpace(mangaDir)
if (availSpace != -1L && availSpace < MIN_DISK_SPACE) {