Skip to content

Commit

Permalink
fix: download job stops all together even if 1 entry is failed to cre…
Browse files Browse the repository at this point in the history
…ate 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
  • Loading branch information
cuong-tran authored Dec 31, 2024
1 parent a66dd25 commit ec97db5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class DownloadProvider(
throw Exception(
context.stringResource(
MR.strings.invalid_location,
downloadsDir?.displayablePath ?: "",
(downloadsDir?.displayablePath ?: "") +
"/${getSourceDirName(source)}/${getMangaDirName(mangaTitle)}",
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ec97db5

Please sign in to comment.