Offer only Windows builds as a replaced itch upload and stop a cancelled update from completing

This commit is contained in:
FX192 committed 2026-10-28 08:47:50 +03:00
1 parent 0e173ed05a
commit 9b44bf798d
3 files changed
+8 -1

No files matched your search

@@ -216,6 +216,7 @@ internal class ItchInstaller(
throw t
}
ItchStaging.merge(work, folder)
if (cancelled.get()) return null
ItchStaging.delete(work)
}
return exe
@@ -38,7 +38,7 @@ internal object ItchUpdates {
val stamp = ItchUploads.updatedAt(current)
return if (stamp > version) ItchUpdate(uploadId, stamp, ItchUploads.filename(current), false) else null
}
val next = ItchUploads.windows(uploads) ?: return null
val next = ItchUploads.windows(uploads)?.takeIf { ItchUploads.windows(it) } ?: return null
val stamp = ItchUploads.updatedAt(next)
if (uploadId.isBlank() && stamp <= version) return null
return ItchUpdate(next.optString("id"), stamp, ItchUploads.filename(next), uploadId.isNotBlank())
@@ -41,6 +41,12 @@ class ItchUpdatesTest {
assertTrue(update.replaced)
}
@Test fun aReplacedUploadWithNoWindowsBuildLeftIsNotOffered() {
val linux = list(upload("8", "2026-10-01T10:00:00Z", windows = false))
assertNull(ItchUpdates.evaluate(linux, "7", "2026-09-01T10:00:00Z"))
assertNull(ItchUpdates.evaluate(linux, "", "2026-09-01T10:00:00Z"))
}
@Test fun anUnknownInstalledVersionNeverReportsAnUpdate() {
assertNull(ItchUpdates.evaluate(list(upload("7", "2026-10-20T10:00:00Z")), "7", ""))
}