MCPcopy Index your code
hub / github.com/tailscale/tailscale / receiveFile

Function receiveFile

cmd/tailscale/cli/file.go:691–711  ·  view source on GitHub ↗
(ctx context.Context, wf apitype.WaitingFile, dir string)

Source from the content-addressed store, hash-verified

689}
690
691func receiveFile(ctx context.Context, wf apitype.WaitingFile, dir string) (targetFile string, size int64, err error) {
692 rc, size, err := localClient.GetWaitingFile(ctx, wf.Name)
693 if err != nil {
694 return "", 0, fmt.Errorf("opening inbox file %q: %w", wf.Name, err)
695 }
696 defer rc.Close()
697 f, err := openFileOrSubstitute(dir, wf.Name, fileGetArgs.conflict)
698 if err != nil {
699 return "", 0, err
700 }
701 // Apply quarantine attribute before copying
702 if err := quarantine.SetOnFile(f); err != nil {
703 return "", 0, fmt.Errorf("failed to apply quarantine attribute to file %v: %v", f.Name(), err)
704 }
705 _, err = io.Copy(f, rc)
706 if err != nil {
707 f.Close()
708 return "", 0, fmt.Errorf("failed to write %v: %v", f.Name(), err)
709 }
710 return f.Name(), size, f.Close()
711}
712
713func runFileGetOneBatch(ctx context.Context, dir string) []error {
714 var wfs []apitype.WaitingFile

Callers 1

runFileGetOneBatchFunction · 0.85

Calls 6

SetOnFileFunction · 0.92
openFileOrSubstituteFunction · 0.85
GetWaitingFileMethod · 0.80
ErrorfMethod · 0.65
CloseMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…