(ctx context.Context, wf apitype.WaitingFile, dir string)
| 689 | } |
| 690 | |
| 691 | func 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 | |
| 713 | func runFileGetOneBatch(ctx context.Context, dir string) []error { |
| 714 | var wfs []apitype.WaitingFile |
no test coverage detected
searching dependent graphs…