From 039471427448347a1c12c39a488a1127a3ea1497 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Wed, 25 Feb 2026 19:05:30 +0600 Subject: [PATCH] Run automatic library updates even when connected to a VPN (#2996) Co-authored-by: jeremiejig <3978761+jeremiejig@users.noreply.github.com> --- CHANGELOG.md | 1 + .../data/library/LibraryUpdateJob.kt | 21 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a13f0fa8d..672ba0099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co - Add a small increment to chapter number before comparison to fix progress sync issues for Suwayomi ([@cpiber](https://github.com/cpiber)) ([#2657](https://github.com/mihonapp/mihon/pull/2675)) - Add all pages of adjacent chapters in the UI instead of only the first or last three ([@AntsyLich](https://github.com/AntsyLich)) ([#2995](https://github.com/mihonapp/mihon/pull/2995)) - Going back now first clears search query on browse extension tab ([@cuong-tran](https://github.com/cuong-tran)) ([#2906](https://github.com/mihonapp/mihon/pull/2906)) +- Automatic library updates now run even when connected to a VPN ([@AntsyLich](https://github.com/AntsyLich)) ([#2773](https://github.com/mihonapp/mihon/pull/2773)) ### Fixed - Fix reader tap zones triggering after scrolling is stopped by tapping ([@NGB-Was-Taken](https://github.com/NGB-Was-Taken)) ([#2680](https://github.com/mihonapp/mihon/pull/2680)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt index f3adddf43..2576eff78 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt @@ -418,10 +418,6 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet */ private const val KEY_CATEGORY = "category" - fun cancelAllWorks(context: Context) { - context.workManager.cancelAllWorkByTag(TAG) - } - fun setupTask( context: Context, prefInterval: Int? = null, @@ -435,16 +431,19 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet } else { NetworkType.CONNECTED } - val networkRequestBuilder = NetworkRequest.Builder() - if (DEVICE_ONLY_ON_WIFI in restrictions) { - networkRequestBuilder.addTransportType(NetworkCapabilities.TRANSPORT_WIFI) - } - if (DEVICE_NETWORK_NOT_METERED in restrictions) { - networkRequestBuilder.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED) + val networkRequest = NetworkRequest.Builder().apply { + removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN) + if (DEVICE_ONLY_ON_WIFI in restrictions) { + addTransportType(NetworkCapabilities.TRANSPORT_WIFI) + } + if (DEVICE_NETWORK_NOT_METERED in restrictions) { + addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED) + } } + .build() val constraints = Constraints.Builder() // 'networkRequest' only applies to Android 9+, otherwise 'networkType' is used - .setRequiredNetworkRequest(networkRequestBuilder.build(), networkType) + .setRequiredNetworkRequest(networkRequest, networkType) .setRequiresCharging(DEVICE_CHARGING in restrictions) .setRequiresBatteryNotLow(true) .build()