Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/decouple thumbnail downloads and cache #581

Merged

Conversation

schroda
Copy link
Collaborator

@schroda schroda commented Jun 19, 2023

Currently all thumbnails are downloaded permanently.
This not only includes thumbnails of mangas that are part of the library but also when browsing a source.
Unless you manually cleanup these files, they will never get deleted.

This PR changes thumbnails to be tmp files, which get saved in the systems tmp folder.
Only thumbnails of mangas, that are part of the library, will be saved permanently.
Once a manga gets added/removed from the library, the permanent thumbnail will get downloaded/deleted.

The logic for this reuses the existing logic of the chapter pages.
There had to be slight adaptions to the interface and classes since the functions for the thumbnails and pages have different number of arguments.
Since they are still classes which have to provide the same behaviour with the same functions (e.g. get image, download image, delete image) I wanted to use the same interface

In case the tmp files should not get saved in the systems tmp folder, this can be changed in a later/separate PR which implements a custom cache (which IMO then should also be used for the pages of chapters)

@schroda schroda force-pushed the feature/decouple_thumbnail_downloads_and_cache branch from 7e88930 to 8c682d4 Compare June 24, 2023 11:18
@@ -331,13 +331,24 @@ object Chapter {
}
}

private fun deleteFilesOf(chapterIds: List<Int>, mangaId: Int) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

choose a better name for this function

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed it to deleteDownloadsFor

}

@FunctionalInterface
interface IFileDownload1<A> : IFileDownload {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make up better names instead of numbering

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh, no clue how to name this, I added "Args" as an suffix
I'm open for better names

fun getChapterDownloadPath(mangaId: Int, chapterId: Int): String {
return applicationDirs.mangaDownloadsRoot + "/" + getChapterDir(mangaId, chapterId)
return applicationDirs.downloadsRoot + "/mangas/" + getChapterDir(mangaId, chapterId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad abstraction here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added mangaDownloadsRoot to app dirs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also we should use a sensible path joiner function instead of hand concatenating them

@schroda schroda force-pushed the feature/decouple_thumbnail_downloads_and_cache branch from 8c682d4 to 57d9aac Compare June 24, 2023 23:34
@schroda schroda marked this pull request as draft June 25, 2023 13:58
@schroda schroda changed the title Feature/decouple thumbnail downloads and cache [WIP] Feature/decouple thumbnail downloads and cache Jun 25, 2023
@schroda schroda force-pushed the feature/decouple_thumbnail_downloads_and_cache branch 3 times, most recently from 01d9723 to 789a6e8 Compare July 2, 2023 22:01
@schroda schroda changed the title [WIP] Feature/decouple thumbnail downloads and cache Feature/decouple thumbnail downloads and cache Jul 2, 2023
@schroda schroda marked this pull request as ready for review July 2, 2023 22:04
@schroda schroda requested a review from AriaMoradi July 9, 2023 10:11
@schroda schroda force-pushed the feature/decouple_thumbnail_downloads_and_cache branch from 789a6e8 to 31b1bca Compare July 13, 2023 11:58
@schroda schroda force-pushed the feature/decouple_thumbnail_downloads_and_cache branch from 31b1bca to 4fdbc05 Compare July 22, 2023 16:12
@schroda schroda force-pushed the feature/decouple_thumbnail_downloads_and_cache branch from 4fdbc05 to bf65476 Compare July 24, 2023 20:21
@schroda schroda force-pushed the feature/decouple_thumbnail_downloads_and_cache branch from bf65476 to 39d3dcb Compare August 4, 2023 22:23
@schroda schroda force-pushed the feature/decouple_thumbnail_downloads_and_cache branch from 39d3dcb to 8e487cc Compare August 9, 2023 17:46
@schroda schroda force-pushed the feature/decouple_thumbnail_downloads_and_cache branch 2 times, most recently from e5c5720 to cb1acd5 Compare August 12, 2023 10:24
When adding/removing manga from/to the library make sure the permanent thumbnail files will get handled properly
@schroda schroda force-pushed the feature/decouple_thumbnail_downloads_and_cache branch from cb1acd5 to c791f1b Compare August 12, 2023 10:26
@Syer10 Syer10 dismissed AriaMoradi’s stale review August 12, 2023 15:10

Inactive reviewer

@Syer10 Syer10 merged commit f2dd67d into Suwayomi:master Aug 12, 2023
2 checks passed
@schroda schroda deleted the feature/decouple_thumbnail_downloads_and_cache branch August 12, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants