Implement unsafe icon cache diagnostics (T-611)
This commit is contained in:
@@ -9,6 +9,11 @@ import (
|
||||
|
||||
var ErrIconRequestStale = errors.New("icon request no longer matches catalog")
|
||||
|
||||
type iconFailureState struct {
|
||||
Identity application.IconEventIdentity
|
||||
Code application.IconFailureCode
|
||||
}
|
||||
|
||||
// ExpectIcon records the newest request identity on the UI goroutine.
|
||||
func (shell *AppShell) ExpectIcon(identity application.IconEventIdentity) error {
|
||||
validated, err := application.NewIconEventIdentity(
|
||||
@@ -45,6 +50,7 @@ func (shell *AppShell) CancelIconRequest(appID, requestID string) bool {
|
||||
return false
|
||||
}
|
||||
delete(shell.iconRequests, appID)
|
||||
delete(shell.iconFailures, appID)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -73,7 +79,10 @@ func (shell *AppShell) ApplyEvent(event application.Event) error {
|
||||
if !hasApplied || !sameIconResource(applied, identity) {
|
||||
shell.ApplyIcon(identity.AppID, nil)
|
||||
}
|
||||
shell.iconFailures[identity.AppID] = iconEvent.ErrorCode
|
||||
shell.iconFailures[identity.AppID] = iconFailureState{
|
||||
Identity: identity,
|
||||
Code: iconEvent.ErrorCode,
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -81,7 +90,7 @@ func (shell *AppShell) ApplyEvent(event application.Event) error {
|
||||
// IconFailure exposes the last failure for diagnostics without raw network data.
|
||||
func (shell *AppShell) IconFailure(appID string) (application.IconFailureCode, bool) {
|
||||
failure, exists := shell.iconFailures[appID]
|
||||
return failure, exists
|
||||
return failure.Code, exists
|
||||
}
|
||||
|
||||
func canonicalIconReference(reference string) string {
|
||||
|
||||
Reference in New Issue
Block a user