mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
Keep the install record out of update merges and drop update results that went stale mid-check
This commit is contained in:
3 files changed
+19
-2
No files matched your search
@@ -5,13 +5,15 @@ import java.nio.file.Files
|
||||
|
||||
internal object ItchStaging {
|
||||
const val DIR = ".droiddeck-update"
|
||||
const val RECORD = ".droiddeck-store.json"
|
||||
|
||||
fun merge(from: File, to: File) {
|
||||
fun merge(from: File, to: File, top: Boolean = true) {
|
||||
for (child in from.listFiles().orEmpty()) {
|
||||
if (top && child.name == RECORD) continue
|
||||
val dest = File(to, child.name)
|
||||
val destPath = dest.toPath()
|
||||
if (child.isDirectory && !Files.isSymbolicLink(child.toPath()) && dest.isDirectory && !Files.isSymbolicLink(destPath)) {
|
||||
merge(child, dest)
|
||||
merge(child, dest, false)
|
||||
continue
|
||||
}
|
||||
if (Files.isSymbolicLink(destPath) || dest.exists()) {
|
||||
|
||||
@@ -94,10 +94,12 @@ internal object ItchUpdates {
|
||||
StoresState.post { total = games.size; done = 0; checking = true }
|
||||
val found = LinkedHashMap<String, ItchUpdate>()
|
||||
val answered = HashSet<String>()
|
||||
val snapshot = HashMap<String, Pair<String, String>>()
|
||||
var failed = false
|
||||
games.forEachIndexed { i, game ->
|
||||
if (i > 0) Thread.sleep(GAP_MS)
|
||||
val extra = game.sidecar.extra
|
||||
snapshot[game.key] = game.sidecar.installVersion to extra["uploadId"].orEmpty()
|
||||
val gameId = extra["gameId"].orEmpty()
|
||||
if (gameId.isNotEmpty()) {
|
||||
val uploads = ItchApi.uploads(key, gameId, extra["downloadKeyId"].orEmpty())
|
||||
@@ -113,6 +115,8 @@ internal object ItchUpdates {
|
||||
StoresState.post {
|
||||
if (started != generation) return@post
|
||||
for (k in answered) {
|
||||
val now = StoresState.installed.firstOrNull { it.key == k } ?: continue
|
||||
if (snapshot[k] != now.sidecar.installVersion to now.sidecar.extra["uploadId"].orEmpty()) continue
|
||||
val u = found[k]
|
||||
if (u != null) available[k] = u else available.remove(k)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user