mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-27 08:16:36 +03:00
Use always 3 characters for downloaded pages. Fixes #181
This commit is contained in:
parent
17a6ea973e
commit
492a24ec17
1 changed files with 7 additions and 8 deletions
|
@ -260,16 +260,15 @@ class DownloadManager(private val context: Context, private val sourceManager: S
|
||||||
// Get the filename for an image given the page
|
// Get the filename for an image given the page
|
||||||
private fun getImageFilename(page: Page): String {
|
private fun getImageFilename(page: Page): String {
|
||||||
val url = page.imageUrl
|
val url = page.imageUrl
|
||||||
val number = page.pageNumber + 1
|
val number = String.format("%03d", page.pageNumber + 1)
|
||||||
|
|
||||||
// Try to preserve file extension
|
// Try to preserve file extension
|
||||||
if (UrlUtil.isJpg(url)) {
|
return when {
|
||||||
return "$number.jpg"
|
UrlUtil.isJpg(url) -> "$number.jpg"
|
||||||
} else if (UrlUtil.isPng(url)) {
|
UrlUtil.isPng(url) -> "$number.png"
|
||||||
return "$number.png"
|
UrlUtil.isGif(url) -> "$number.gif"
|
||||||
} else if (UrlUtil.isGif(url)) {
|
else -> Uri.parse(url).lastPathSegment.replace(imageFilenameRegex, "_")
|
||||||
return "$number.gif"
|
|
||||||
}
|
}
|
||||||
return Uri.parse(url).lastPathSegment.replace(imageFilenameRegex, "_")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isImageDownloaded(imagePath: File): Boolean {
|
private fun isImageDownloaded(imagePath: File): Boolean {
|
||||||
|
|
Loading…
Reference in a new issue