diff --git a/app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt b/app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt index 184977ccea..cf3cfc400e 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt @@ -256,19 +256,31 @@ object UpscaleComponent { fun ensureBridges(context: Context) { val app = context.applicationContext + if (localBridges() != null && !AddonPack.UPSCALE.installed(app)) { + Thread({ stageBridges(app) }, "upscale-bridges").start() + return + } if (!AddonPack.UPSCALE.available) return AddonPack.UPSCALE.ensure(app) { stageBridges(it) } } - /** Copies the add-on pack's bridges/ tree into the rootfs (once per pack version). */ + /** A bridges/ tree beside the data files under Download/droiddeck-upscale: builds without a published pack. */ + @Suppress("DEPRECATION") + private fun localBridges(): File? = runCatching { + File(Environment.getExternalStorageDirectory(), "Download/$LOCAL_COPY/bridges") + .takeIf { File(it, "x86_64-windows/libxess.dll").isFile } + }.getOrNull() + + /** Copies the add-on pack's bridges/ tree (or the local one) into the rootfs, once per version. */ @Synchronized fun stageBridges(context: Context): Boolean { - val pack = AddonPack.UPSCALE.takeIf { it.installed(context) }?.dir(context) ?: return bridgesReady(context) - val source = File(pack, "bridges") + val pack = AddonPack.UPSCALE.takeIf { it.installed(context) }?.dir(context) + val source = pack?.let { File(it, "bridges") } ?: localBridges() ?: return bridgesReady(context) if (!source.isDirectory) return false + val version = pack?.name ?: ("local-" + File(source, "x86_64-windows/libxess.dll").let { it.length().toString() + "-" + it.lastModified() }) val target = bridgesDir(context) val stamp = File(target, BRIDGES_STAMP) - if (bridgesReady(context) && runCatching { stamp.readText() }.getOrNull() == pack.name) return true + if (bridgesReady(context) && runCatching { stamp.readText() }.getOrNull() == version) return true var ok = true source.walkTopDown().filter { it.isFile }.forEach { file -> val out = File(target, file.relativeTo(source).path) @@ -280,8 +292,8 @@ object UpscaleComponent { }.getOrDefault(false) && ok staged.delete() } - if (ok) runCatching { stamp.writeText(pack.name) } - Log.i(TAG, "upscaler bridges staged from pack ${pack.name}: $ok") + if (ok) runCatching { stamp.writeText(version) } + Log.i(TAG, "upscaler bridges staged from $version: $ok") return ok }