mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
feat(upscale): bridges from Download/droiddeck-upscale/bridges when the pack is not installed
Branch builds publish no add-on packs; a local copy beside the data files lets such a build be tested.
This commit is contained in:
1 parent
02d57b2a78
commit
c0af05f103
1 file changed
+18
-6
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user