Skip to content

Commit c2fed71

Browse files
Update watch.go
1 parent 1505b44 commit c2fed71

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

internal/cli/backup/restores/watch.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import (
2727
atlasv2 "go.mongodb.org/atlas-sdk/v20241113004/admin"
2828
)
2929

30+
const deliveryTypeDownload = "download"
31+
3032
type WatchOpts struct {
3133
cli.ProjectOpts
3234
cli.WatchOpts
@@ -54,7 +56,19 @@ func (opts *WatchOpts) watcher() (any, bool, error) {
5456
return nil, false, err
5557
}
5658

57-
return nil, result.GetExpired() || result.GetCancelled() || result.GetFailed() || result.HasFinishedAt(), nil
59+
return nil, stopWatcher(result), nil
60+
}
61+
62+
func stopWatcher(result *atlasv2.DiskBackupSnapshotRestoreJob) bool {
63+
if result.GetExpired() || result.GetCancelled() || result.GetFailed() || result.HasFinishedAt() {
64+
return true
65+
}
66+
67+
if result.GetDeliveryType() == deliveryTypeDownload && len(result.GetDeliveryUrl()) > 0 {
68+
return true
69+
}
70+
71+
return false
5872
}
5973

6074
func (opts *WatchOpts) watcherFlexCluster() (any, bool, error) {

0 commit comments

Comments
 (0)