Implement resumable download queue (T-301)

This commit is contained in:
ila
2026-07-16 19:49:06 +08:00
parent 2d302b731a
commit 8dad40f934
27 changed files with 5498 additions and 18 deletions
+45
View File
@@ -0,0 +1,45 @@
package application
// DownloadStartedPayload begins one transfer attempt. A later attempt may
// reset Done when a remote entity cannot be safely resumed.
type DownloadStartedPayload struct {
Attempt uint64
Done int64
TotalKnown bool
Total int64
}
// DownloadProgressPayload reports monotonic progress within one attempt.
type DownloadProgressPayload struct {
Attempt uint64
Done int64
TotalKnown bool
Total int64
SpeedBytesSec int64
}
// DownloadPausedPayload maps to domain queued while preserving pause intent.
type DownloadPausedPayload struct {
Attempt uint64
Done int64
}
// DownloadCompletedPayload means bytes are durably downloaded but still
// untrusted. T-302 must verify the signed Catalog identity, size and hashes.
type DownloadCompletedPayload struct {
Attempt uint64
Done int64
Path string
}
// DownloadFailedPayload carries a stable low-level transfer/storage code.
type DownloadFailedPayload struct {
Attempt uint64
Done int64
ErrorCode string
}
// DownloadCanceledPayload confirms cleanup and suppresses the old attempt.
type DownloadCanceledPayload struct {
Attempt uint64
}
+2
View File
@@ -11,6 +11,7 @@ const (
EventDownloadPaused EventType = "DownloadPaused"
EventDownloadCompleted EventType = "DownloadCompleted"
EventDownloadFailed EventType = "DownloadFailed"
EventDownloadCanceled EventType = "DownloadCanceled"
EventInstallCompleted EventType = "InstallCompleted"
EventInstallRolledBack EventType = "InstallRolledBack"
EventAppStarted EventType = "AppStarted"
@@ -26,6 +27,7 @@ var validEventTypes = map[EventType]struct{}{
EventDownloadPaused: {},
EventDownloadCompleted: {},
EventDownloadFailed: {},
EventDownloadCanceled: {},
EventInstallCompleted: {},
EventInstallRolledBack: {},
EventAppStarted: {},
+1
View File
@@ -11,6 +11,7 @@ func TestEventTypeValid(t *testing.T) {
EventDownloadPaused,
EventDownloadCompleted,
EventDownloadFailed,
EventDownloadCanceled,
EventInstallCompleted,
EventInstallRolledBack,
EventAppStarted,