Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d3bee09

Browse files
committedMay 16, 2024·
Handling conflict
1 parent 935fbbe commit d3bee09

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
 

‎command/ota/cancel.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ func CancelOta(otaid string, cred *config.Credentials) error {
2121
if err != nil {
2222
return err
2323
}
24+
// No error, get current status
25+
res, err := otapi.GetOtaStatusByOtaID(otaid, 1, otaapi.OrderDesc)
26+
if err != nil {
27+
return err
28+
}
29+
if res != nil {
30+
feedback.PrintResult(res.Ota)
31+
}
32+
return nil
2433
}
2534

2635
return nil

‎internal/ota-api/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838
)
3939

4040
var ErrAlreadyInProgress = fmt.Errorf("already in progress")
41+
var ErrAlreadyCancelled = fmt.Errorf("already cancelled")
4142

4243
type OtaApiClient struct {
4344
client *http.Client
@@ -236,7 +237,7 @@ func (c *OtaApiClient) CancelOta(otaid string) (bool, error) {
236237
} else if res.StatusCode == 404 || res.StatusCode == 400 {
237238
return false, fmt.Errorf("ota-id %s not found", otaid)
238239
} else if res.StatusCode == 409 {
239-
return false, ErrAlreadyInProgress
240+
return false, ErrAlreadyCancelled
240241
}
241242

242243
return false, err

0 commit comments

Comments
 (0)
Please sign in to comment.