ipn/ipnlocal: always set Notify.FilesWaiting, set IncomingFiles non-nil when empty

This commit is contained in:
Brad Fitzpatrick
2021-04-09 07:57:32 -07:00
parent b0af15ff5c
commit 20e7646b8d
2 changed files with 20 additions and 5 deletions

View File

@@ -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())
}