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

Add advanced Library setting to allow library manga's titles to update from source #1182

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

FlaminSarge
Copy link
Contributor

@FlaminSarge FlaminSarge commented Sep 1, 2024

This adds a setting under Advanced > Library to allow any entry, not just favorites, to update their titles from source.
It attempts to move the downloaded files as well by renaming the entry's download folder. It does not currently attempt to move downloaded files into an existing folder (if another title exists/conflicts).

A bit of context from the previous change to allow non-favorites to update title from source: 58a871c

Tested cases:

  • Auto-update metadata setting disabled, title update setting enabled: refreshing library does not update to new title, but refreshing from manga details page does
  • Auto-update metadata setting enabled, title update setting enabled: refreshing library does update to new title, as does refreshing from manga details page
  • Title update setting disabled: neither refreshing library nor manga details page updates the title

Images

Image 1 Image 2
Screenshot 2024-08-31 at 5 35 21 PM Screenshot 2024-08-31 at 5 35 53 PM

@FlaminSarge
Copy link
Contributor Author

FlaminSarge commented Sep 1, 2024

I was considering putting this under the "Automatically update metadata" setting under Library settings; unsure whether it should go there or under Advanced, given how it's a slightly more dangerous setting when it comes to Download handling.

I need advice on better download handling for this PR before I move it out of draft, as while a simple rename works for some cases, it doesn't handle the edge case of existing folder nor do I do any cache handling yet.

Another discussion that came up is changing the Auto-update metadata setting (or this setting) to be a multiselect preference with the various metadata fields as options, such that a user can choose to e.g. update Title but preserve Cover (for whatever purpose). Unsure if that's overdoing it here.

* @param manga the manga to rename
* @param newTitle the new manga title.
*/
fun renameManga(source: Source, manga: Manga, newTitle: String) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What will happen with downloading entries, all those _tmp files?

Copy link
Contributor Author

@FlaminSarge FlaminSarge Mar 24, 2025

Choose a reason for hiding this comment

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

The user gets "an unknown error occured" and has to retry the download. This is an existing case if a user tries to download manga that isn't in their library and then refreshes the info so the title changes, as well.

The exception is:

Failed to createFile
    java.lang.IllegalArgumentException: Failed to determine if primary:Tachi/downloads/MangaDex (EN)/pants/Puzzle Kings_Ch.54_tmp is child of primary:Tachi: java.io.FileNotFoundException: Missing file for primary:Tachi/downloads/MangaDex (EN)/pants/Puzzle Kings_Ch.54_tmp at /storage/emulated/0/Tachi/downloads/MangaDex (EN)/pants/Puzzle Kings_Ch.54_tmp
    	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
    	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
    	at android.content.ContentProviderProxy.call(ContentProviderNative.java:732)
    	at android.content.ContentResolver.call(ContentResolver.java:2450)
    	at android.provider.DocumentsContract.createDocument(DocumentsContract.java:1380)
    	at com.hippo.unifile.DocumentsContractApi21.createFile(DocumentsContractApi21.java:56)
    	at com.hippo.unifile.TreeDocumentFile.createFile(TreeDocumentFile.java:86)
    	at eu.kanade.tachiyomi.data.download.Downloader$downloadImage$2.invokeSuspend(Downloader.kt:478)
    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
    	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
    	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
    	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)```

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made it so that a manga gets removed from queue if it's getting renamed; this will handle both the new case of in-library manga as well as the existing case of non-library manga that are being downloaded when the name change happens.

@FlaminSarge
Copy link
Contributor Author

FlaminSarge commented Mar 11, 2025

Needs cache handling before this can be merged; right now, if a manga gets renamed in this way, the download cache doesn't know about it and the cache still thinks the old manga dir has the downloads, not the new one.

@cuong-tran
Copy link
Contributor

Time to migrate to use something like hash(url) as a preceeding of folder name, that should address various other issues.

@FlaminSarge FlaminSarge force-pushed the titles branch 2 times, most recently from 7a48484 to 50a4479 Compare March 24, 2025 08:09
@FlaminSarge FlaminSarge marked this pull request as ready for review March 24, 2025 08:12
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