Compare commits

...

4 Commits

Author SHA1 Message Date
FlaminSarge
26df3ae9a4
Merge f77f9b1f94 into 47b0e9d7be 2024-10-24 19:43:04 +09:00
Mend Renovate
47b0e9d7be
Pin actions/upload-artifact action to b4b15b8 (#1363)
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
2024-10-24 03:56:06 +06:00
AntsyLich
d4bf19f957
Make renovate group github action deps 2024-10-24 03:35:46 +06:00
FlaminSarge
f77f9b1f94 Add advanced Library setting to allow library manga's titles to update from source 2024-10-15 06:01:18 -07:00
10 changed files with 73 additions and 12 deletions

View File

@ -2,5 +2,12 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json", "$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"], "extends": ["config:base"],
"labels": ["Dependencies"], "labels": ["Dependencies"],
"semanticCommits": "disabled" "semanticCommits": "disabled",
"packageRules": [
{
"groupName": "GitHub Actions",
"matchManagers": ["github-actions"],
"pinDigests": true,
}
]
} }

View File

@ -44,13 +44,13 @@ jobs:
run: ./gradlew spotlessCheck assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest run: ./gradlew spotlessCheck assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest
- name: Upload APK - name: Upload APK
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with: with:
name: arm64-v8a-${{ github.sha }} name: arm64-v8a-${{ github.sha }}
path: app/build/outputs/apk/standard/release/app-standard-arm64-v8a-release-unsigned.apk path: app/build/outputs/apk/standard/release/app-standard-arm64-v8a-release-unsigned.apk
- name: Upload mapping - name: Upload mapping
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with: with:
name: mapping-${{ github.sha }} name: mapping-${{ github.sha }}
path: app/build/outputs/mapping/standardRelease path: app/build/outputs/mapping/standardRelease

View File

@ -39,13 +39,13 @@ jobs:
run: ./gradlew spotlessCheck assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest run: ./gradlew spotlessCheck assembleStandardRelease testReleaseUnitTest testStandardReleaseUnitTest
- name: Upload APK - name: Upload APK
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with: with:
name: arm64-v8a-${{ github.sha }} name: arm64-v8a-${{ github.sha }}
path: app/build/outputs/apk/standard/release/app-standard-arm64-v8a-release-unsigned.apk path: app/build/outputs/apk/standard/release/app-standard-arm64-v8a-release-unsigned.apk
- name: Upload mapping - name: Upload mapping
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with: with:
name: mapping-${{ github.sha }} name: mapping-${{ github.sha }}
path: app/build/outputs/mapping/standardRelease path: app/build/outputs/mapping/standardRelease

View File

@ -2,7 +2,10 @@ package eu.kanade.domain.manga.interactor
import eu.kanade.domain.manga.model.hasCustomCover import eu.kanade.domain.manga.model.hasCustomCover
import eu.kanade.tachiyomi.data.cache.CoverCache import eu.kanade.tachiyomi.data.cache.CoverCache
import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import tachiyomi.domain.library.service.LibraryPreferences
import tachiyomi.domain.manga.interactor.FetchInterval import tachiyomi.domain.manga.interactor.FetchInterval
import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.manga.model.MangaUpdate import tachiyomi.domain.manga.model.MangaUpdate
@ -27,10 +30,13 @@ class UpdateManga(
} }
suspend fun awaitUpdateFromSource( suspend fun awaitUpdateFromSource(
source: Source,
localManga: Manga, localManga: Manga,
remoteManga: SManga, remoteManga: SManga,
manualFetch: Boolean, manualFetch: Boolean,
coverCache: CoverCache = Injekt.get(), coverCache: CoverCache = Injekt.get(),
libraryPreferences: LibraryPreferences = Injekt.get(),
downloadManager: DownloadManager = Injekt.get()
): Boolean { ): Boolean {
val remoteTitle = try { val remoteTitle = try {
remoteManga.title remoteManga.title
@ -38,8 +44,12 @@ class UpdateManga(
"" ""
} }
// if the manga isn't a favorite, set its title from source and update in db // if the manga isn't a favorite (or 'update titles' preference is enabled), set its title from source and update in db
val title = if (remoteTitle.isEmpty() || localManga.favorite) null else remoteTitle val title =
if (remoteTitle.isNotEmpty() && (!localManga.favorite || libraryPreferences.updateMangaTitles().get()))
remoteTitle
else
null
val coverLastModified = val coverLastModified =
when { when {
@ -59,7 +69,7 @@ class UpdateManga(
val thumbnailUrl = remoteManga.thumbnail_url?.takeIf { it.isNotEmpty() } val thumbnailUrl = remoteManga.thumbnail_url?.takeIf { it.isNotEmpty() }
return mangaRepository.update( val success = mangaRepository.update(
MangaUpdate( MangaUpdate(
id = localManga.id, id = localManga.id,
title = title, title = title,
@ -74,6 +84,10 @@ class UpdateManga(
initialized = true, initialized = true,
), ),
) )
if (success && title != null) {
downloadManager.renameManga(source, localManga, title)
}
return success;
} }
suspend fun awaitUpdateFetchInterval( suspend fun awaitUpdateFetchInterval(

View File

@ -62,6 +62,7 @@ import okhttp3.Headers
import tachiyomi.core.common.util.lang.launchNonCancellable import tachiyomi.core.common.util.lang.launchNonCancellable
import tachiyomi.core.common.util.lang.withUIContext import tachiyomi.core.common.util.lang.withUIContext
import tachiyomi.core.common.util.system.logcat import tachiyomi.core.common.util.system.logcat
import tachiyomi.domain.library.service.LibraryPreferences
import tachiyomi.domain.manga.interactor.ResetViewerFlags import tachiyomi.domain.manga.interactor.ResetViewerFlags
import tachiyomi.i18n.MR import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
@ -84,6 +85,7 @@ object SettingsAdvancedScreen : SearchableSettings {
val basePreferences = remember { Injekt.get<BasePreferences>() } val basePreferences = remember { Injekt.get<BasePreferences>() }
val networkPreferences = remember { Injekt.get<NetworkPreferences>() } val networkPreferences = remember { Injekt.get<NetworkPreferences>() }
val libraryPreferences = remember { Injekt.get<LibraryPreferences>() }
return listOf( return listOf(
Preference.PreferenceItem.TextPreference( Preference.PreferenceItem.TextPreference(
@ -124,7 +126,7 @@ object SettingsAdvancedScreen : SearchableSettings {
getBackgroundActivityGroup(), getBackgroundActivityGroup(),
getDataGroup(), getDataGroup(),
getNetworkGroup(networkPreferences = networkPreferences), getNetworkGroup(networkPreferences = networkPreferences),
getLibraryGroup(), getLibraryGroup(libraryPreferences = libraryPreferences),
getReaderGroup(basePreferences = basePreferences), getReaderGroup(basePreferences = basePreferences),
getExtensionsGroup(basePreferences = basePreferences), getExtensionsGroup(basePreferences = basePreferences),
) )
@ -285,7 +287,9 @@ object SettingsAdvancedScreen : SearchableSettings {
} }
@Composable @Composable
private fun getLibraryGroup(): Preference.PreferenceGroup { private fun getLibraryGroup(
libraryPreferences: LibraryPreferences
): Preference.PreferenceGroup {
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
val context = LocalContext.current val context = LocalContext.current
@ -313,6 +317,11 @@ object SettingsAdvancedScreen : SearchableSettings {
} }
}, },
), ),
Preference.PreferenceItem.SwitchPreference(
pref = libraryPreferences.updateMangaTitles(),
title = stringResource(MR.strings.pref_update_library_manga_titles),
subtitle = stringResource(MR.strings.pref_update_library_manga_titles_summary),
),
), ),
) )
} }

View File

@ -327,6 +327,33 @@ class DownloadManager(
} }
} }
/**
* Renames manga download folder
*
* @param source the source of the manga.
* @param manga the manga to rename
* @param newTitle the new manga title.
*/
fun renameManga(source: Source, manga: Manga, newTitle: String) {
val oldFolder = provider.findMangaDir(manga.title, source) ?: return
val newName = provider.getMangaDirName(newTitle)
if (oldFolder.name == newName) return
val capitalizationChanged = oldFolder.name.equals(newName, ignoreCase = true)
if (capitalizationChanged) {
val tempName = newName + Downloader.TMP_DIR_SUFFIX
if (!oldFolder.renameTo(tempName)) {
logcat(LogPriority.ERROR) { "Failed to rename manga download folder: ${oldFolder.name}" }
return
}
}
if (!oldFolder.renameTo(newName)) {
logcat(LogPriority.ERROR) { "Failed to rename manga download folder: ${oldFolder.name}" }
}
}
/** /**
* Renames an already downloaded chapter * Renames an already downloaded chapter
* *

View File

@ -336,7 +336,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
// Update manga metadata if needed // Update manga metadata if needed
if (libraryPreferences.autoUpdateMetadata().get()) { if (libraryPreferences.autoUpdateMetadata().get()) {
val networkManga = source.getMangaDetails(manga.toSManga()) val networkManga = source.getMangaDetails(manga.toSManga())
updateManga.awaitUpdateFromSource(manga, networkManga, manualFetch = false, coverCache) updateManga.awaitUpdateFromSource(source, manga, networkManga, manualFetch = false, coverCache)
} }
val chapters = source.getChapterList(manga.toSManga()) val chapters = source.getChapterList(manga.toSManga())

View File

@ -265,7 +265,7 @@ class MangaScreenModel(
try { try {
withIOContext { withIOContext {
val networkManga = state.source.getMangaDetails(state.manga.toSManga()) val networkManga = state.source.getMangaDetails(state.manga.toSManga())
updateManga.awaitUpdateFromSource(state.manga, networkManga, manualFetch) updateManga.awaitUpdateFromSource(state.source, state.manga, networkManga, manualFetch)
} }
} catch (e: Throwable) { } catch (e: Throwable) {
// Ignore early hints "errors" that aren't handled by OkHttp // Ignore early hints "errors" that aren't handled by OkHttp

View File

@ -188,6 +188,8 @@ class LibraryPreferences(
ChapterSwipeAction.ToggleRead, ChapterSwipeAction.ToggleRead,
) )
fun updateMangaTitles() = preferenceStore.getBoolean("pref_update_library_manga_titles", false)
// endregion // endregion
enum class ChapterSwipeAction { enum class ChapterSwipeAction {

View File

@ -610,6 +610,8 @@
<string name="pref_verbose_logging">Verbose logging</string> <string name="pref_verbose_logging">Verbose logging</string>
<string name="pref_verbose_logging_summary">Print verbose logs to system log (reduces app performance)</string> <string name="pref_verbose_logging_summary">Print verbose logs to system log (reduces app performance)</string>
<string name="pref_debug_info">Debug info</string> <string name="pref_debug_info">Debug info</string>
<string name="pref_update_library_manga_titles">Allow title changes for library entries</string>
<string name="pref_update_library_manga_titles_summary">If a source has a different title for an entry than the one stored in the library, update it to match the source\'s title.</string>
<!-- About section --> <!-- About section -->
<string name="website">Website</string> <string name="website">Website</string>