jobobby04 / TachiyomiSY

Free and open source manga reader for Android
Apache License 2.0
2.45k stars 135 forks source link

[Bug] nhentai downloaded badge not showing #54

Closed yooman1213 closed 3 years ago

yooman1213 commented 4 years ago

After downloading a chapter from nhentai and the force closing app from task manager (swiping from navigation button) the green downloaded badge is missing after loading the library, and it only happen to nhentai downloaded doujin / manga, but it can be open without connection, and the doujin/manga cant be deleted from app


Device information =

Expected behavior The green downloaded badge not missing

Actual behavior The green downloaded badge is missing

scb261 commented 3 years ago

The bug is also present for exhentai and probably other internal sources. I did some debugging, but my knowledge isn't enough to resolve this. Maybe it will help someone else or maybe someone could give me a hint, so I'm posting here what I got.

https://github.com/jobobby04/TachiyomiSY/blob/a8f2f0356242bf259ab12fffd37c27cac6c4fb2b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt#L124-L132

Set breakpoint on line 125 or 127 (result will be different depending on the line). Now open the app with connected debugger (you need to catch it when app is opening).

When you set breakpoint on line 125 and Step Over (F8) once, look at the size of onlineSources. Remember this number (in my case it's 133). You can also copy onlineSources' elements into notepad to compare them with the next result. Continue executing, the bug will be absent.

When you set breakpoint on line 127, you'll see that size of onlineSources is 6 less than previous case (in my case it's 126). If you compare its elements to previous result, you'll see that internal sources (like nhentai and e-hentai) are absent and therefore corresponding folders will be filtered out on lines 130-132. The bug will be present.

Some other details:

jobobby04 commented 3 years ago

Thanks, that was exactly what I needed to fix it! I narrowed it down to the extension versions, when installed, will take control of the folder even though they should be blacklisted, so I did just that, blacklisted them 😄 Here is the fix if you want to take a look at it https://github.com/jobobby04/TachiyomiSY/commit/ae48c1d7d4430f52979a734dcaad76cabdc90cff This will be closed when the next release is out

scb261 commented 3 years ago

Just pulled and tried out - the bug is still present. And I don't see how ae48c1d would fix it. The problem is that internal sources are missing from onlineSources, and ae48c1d added filter for some reason. The real problem somewhere in sourceManager since sourceManager.getOnlineSources() doesn't return full list. And when I'm trying to debug inside it, the bug for some reason disappears (at least in a8f2f03, didn't try the last one).

ae48c1d says that it fixes the bug when extension is also installed, but I don't have nhentai and exhentai extensions and the bug is present. Well, I did have them installed before, maybe the app remembers it, idk. Edit: just tried HBrowse (never installed extension for it before) and the bug is present.

jobobby04 commented 3 years ago

I was just about to take a deeper look into it, I saw it still happening on my emulator 😄

jobobby04 commented 3 years ago

Well dam, I have narrowed it down to the checkrenew running too early, before the source manager has time to register the internal sources

jobobby04 commented 3 years ago

I found a good fix, the flow wasn't registering the sources fast enough, so I changed it to a immediate flow and it now works properly Here is the fix if you want to take a look at it, the important part is the init edits in the SourceManager https://github.com/jobobby04/TachiyomiSY/commit/ff48e891610ffbd088fc10f70dcb5a93491c82cd