forked from tailscale/tailscale
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ipn/localapi: add support for multipart POST to file-put
This allows sending multiple files via Taildrop in one request. Progress is tracked via ipn.Notify. Updates tailscale/corp#18202 Signed-off-by: Percy Wegmann <percy@tailscale.com>
- Loading branch information
Showing
5 changed files
with
300 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// 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}) | ||
} |
Oops, something went wrong.