mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-23 17:31:43 +00:00
35 lines
821 B
Go
35 lines
821 B
Go
![]() |
// Copyright (c) Tailscale Inc & AUTHORS
|
||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||
|
|
||
|
package ipnlocal
|
||
|
|
||
|
import (
|
||
|
"slices"
|
||
|
"strings"
|
||
|
|
||
|
"tailscale.com/ipn"
|
||
|
)
|
||
|
|
||
|
func (b *LocalBackend) UpdateOutgoingFiles(updates map[string]ipn.OutgoingFile) {
|
||
|
b.mu.Lock()
|
||
|
if b.outgoingFiles == nil {
|
||
|
b.outgoingFiles = make(map[string]*ipn.OutgoingFile, len(updates))
|
||
|
}
|
||
|
for id, file := range updates {
|
||
|
b.outgoingFiles[id] = &file
|
||
|
}
|
||
|
outgoingFiles := make([]*ipn.OutgoingFile, 0, len(b.outgoingFiles))
|
||
|
for _, file := range b.outgoingFiles {
|
||
|
outgoingFiles = append(outgoingFiles, file)
|
||
|
}
|
||
|
b.mu.Unlock()
|
||
|
slices.SortFunc(outgoingFiles, func(a, b *ipn.OutgoingFile) int {
|
||
|
t := a.Started.Compare(b.Started)
|
||
|
if t != 0 {
|
||
|
return t
|
||
|
}
|
||
|
return strings.Compare(a.Name, b.Name)
|
||
|
})
|
||
|
b.send(ipn.Notify{OutgoingFiles: outgoingFiles})
|
||
|
}
|