diff --git a/ipn/backend.go b/ipn/backend.go index 9e143e1c7..64dd7ccd8 100644 --- a/ipn/backend.go +++ b/ipn/backend.go @@ -67,8 +67,17 @@ type Notify struct { BackendLogID *string // public logtail id used by backend PingResult *ipnstate.PingResult - FilesWaiting *empty.Message `json:",omitempty"` - IncomingFiles []PartialFile `json:",omitempty"` + // FilesWaiting if non-nil means that files are buffered in + // the Tailscale daemon and ready for local transfer to the + // user's preferred storage location. + FilesWaiting *empty.Message `json:",omitempty"` + + // IncomingFiles, if non-nil, specifies which files are in the + // process of being received. A nil IncomingFiles means this + // Notify should not update the state of file transfers. A non-nil + // but empty IncomingFiles means that no files are in the middle + // of being transferred. + IncomingFiles []PartialFile `json:",omitempty"` // LocalTCPPort, if non-nil, informs the UI frontend which // (non-zero) localhost TCP port it's listening on. diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index a973fa68b..c6031209a 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -927,6 +927,7 @@ func (b *LocalBackend) readPoller() { func (b *LocalBackend) send(n ipn.Notify) { b.mu.Lock() notifyFunc := b.notify + apiSrv := b.peerAPIServer b.mu.Unlock() if notifyFunc == nil { @@ -934,6 +935,10 @@ func (b *LocalBackend) send(n ipn.Notify) { return } + if apiSrv != nil && apiSrv.hasFilesWaiting() { + n.FilesWaiting = &empty.Message{} + } + n.Version = version.Long notifyFunc(n) } @@ -949,9 +954,10 @@ func (b *LocalBackend) sendFileNotify() { return } - if apiSrv.hasFilesWaiting() { - n.FilesWaiting = &empty.Message{} - } + // Make sure we always set n.IncomingFiles non-nil so it gets encoded + // in JSON to clients. They distinguish between empty and non-nil + // to know whether a Notify should be able about files. + n.IncomingFiles = make([]ipn.PartialFile, 0) for f := range b.incomingFiles { n.IncomingFiles = append(n.IncomingFiles, f.PartialFile()) }