forked from aniyomiorg/aniyomi
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathcommit_diff.txt
More file actions
69 lines (66 loc) · 8.13 KB
/
Copy pathcommit_diff.txt
File metadata and controls
69 lines (66 loc) · 8.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
commit 4a66b8b5df5b64b7a55e6f80a98dea559dce1dca
Author: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
Date: Fri Jul 10 00:02:34 2026 +0600
Fix HTTP Error 416 not being handled properly for resumable downloads
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27d42d3b1a..e64c5ec497 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
- Fix Hikka search throwing error due to unclosed response ([@MajorTanya](https://github.com/MajorTanya)) ([#3548](https://github.com/mihonapp/mihon/pull/3548))
- Add support for [MangaBaka](https://mangabaka.org) tracker ([@MajorTanya](https://github.com/MajorTanya)) ([#3047](https://github.com/mihonapp/mihon/pull/3047))
- Support resumable image downloads if supported by source ([@xMohnad](https://github.com/xMohnad)) ([#3167](https://github.com/mihonapp/mihon/pull/3167))
+ - Fix HTTP Error 416 not being handled properly ([@AntsyLich](https://github.com/AntsyLich)) ([#3563](https://github.com/mihonapp/mihon/pull/3563))
- Display authors and description in Shikimori search results ([@MajorTanya](https://github.com/MajorTanya)) ([#3499](https://github.com/mihonapp/mihon/pull/3499))
- Invalidate download cache after backup restore ([@leodyversemilla07](https://github.com/leodyversemilla07)) ([#3096](https://github.com/mihonapp/mihon/pull/3096))
- Add setting to control vertical chapter navigator height ([@AntsyLich](https://github.com/AntsyLich)) ([#3528](https://github.com/mihonapp/mihon/pull/3528))
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt
index d29638df05..a1e5544edf 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt
@@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.data.cache.ChapterCache
import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.data.library.LibraryUpdateNotifier
import eu.kanade.tachiyomi.data.notification.NotificationHandler
+import eu.kanade.tachiyomi.network.HttpException
import eu.kanade.tachiyomi.source.UnmeteredSource
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.online.HttpSource
@@ -42,7 +43,6 @@ import mihon.core.archive.ZipWriter
import nl.adaptivity.xmlutil.serialization.XML
import okhttp3.Response
import tachiyomi.core.common.i18n.stringResource
-import tachiyomi.core.common.storage.extension
import tachiyomi.core.common.util.lang.launchIO
import tachiyomi.core.common.util.lang.launchNow
import tachiyomi.core.common.util.lang.withIOContext
@@ -482,22 +482,19 @@ class Downloader(
val file = tmpDir.findFile("$filename.tmp")
?: tmpDir.createFile("$filename.tmp")!!
- val response = source.getImage(page, file.length())
-
try {
- response.body
- .source()
- .saveTo(
+ source.getImage(page, file.length()).use {
+ it.body.source().saveTo(
// If the server supports partial downloads (HTTP 206),
// append to the existing file.
// Otherwise, start from scratch and overwrite the file.
- file.openOutputStream(response.code == 206),
+ stream = file.openOutputStream(it.code == 206),
)
- val extension = getImageExtension(response, file)
- file.renameTo("$filename.$extension")
- } catch (e: Exception) {
- response.close()
- if (response.code == 416) {
+ val extension = getImageExtension(it, file)
+ file.renameTo("$filename.$extension")
+ }
+ } catch (e: HttpException) {
+ if (e.code == 416) {
file.delete()
}
throw e