aniyomiorg / aniyomi

An app for manga and anime
https://aniyomi.org
Apache License 2.0
4.53k stars 283 forks source link

Aniyomi needs to implicitly trust the downloaded chapters cache file #1555

Open demonic-avenger opened 2 months ago

demonic-avenger commented 2 months ago

Steps to reproduce

Steps to reproduce

Download some Manga chapters.
Set Filter to show Downloaded (checked).
Fully close Aniyomi.
Open Aniyomi.

Expected behavior

The Filtered series with downloaded chapters should be displayed within a reasonable amount of time.

Actual behavior

Filtered series with downloaded chapters take a ridiculous amount of time to display giving the impression that the downloaded chapters are missing or Aniyomi is misbehaving in some way.

Crash logs

No response

Aniyomi version

0.15.2.4

Android version

Android 13

Device

Redmi note 9

Other details

This issue has existed since Tachiyomi 0.15.0 as far as I know when it was updated to use Scoped Storage. While my kneejerk reactive response would be: "Just roll back that update," I know that it was implemented because Android is supposed to make this mandatory in a future version, for better and moreso for worse.

In any case, Tachiyomi and now Aniyomi seems to verify the existence of the manga chapters downloaded locally upon application startup. With Scoped Storage in place, this process is extraordinarily slow and it gets slower with more downloaded chapters. This also causes a number of other, similar issues like for instance, updating your library then downloading unread chapters: Aniyomi will typically give the appearance of doing nothing while in actuality it is still verifying the presence of downloaded chapters that occurs when it is started. Give it enough time and it will begin downloading the unread chapters as it goes about verifying each series' downloaded chapters.

I would suggest that upon startup, Aniyomi no longer verifies all downloaded manga chapters and instead just implicitly trusts the cached download data. I'm assuming that the cache is basically a list of all downloaded chapters, maybe in .xml format? If the user attempts to read a chapter that, according to the cache, indicates the chapter is downloaded but it turns out the required files are missing, an error window pops up explaining that the downloaded chapter does not exist and this may be due to the user deleting or moving it with an external program or the download cache file is corrupted. It should offer options to Invalidate the Downloads Index to rebuild the cache file, read the chapter online, or cancel (close the window).

Acknowledgements