+ }
+ }
+
+ case PktTypeFreq:
+ if noFreq {
+ return nil
+ }
+ src := string(pkt.Path[:int(pkt.PathLen)])
+ les := append(les, LE{"Type", "freq"}, LE{"Src", src})
+ if filepath.IsAbs(src) {
+ err = errors.New("non-relative source path")
+ ctx.LogE(
+ "rx-non-rel", les, err,
+ func(les LEs) string {
+ return fmt.Sprintf(
+ "Tossing freq %s/%s (%s): %s: notifying",
+ sender.Name, pktName,
+ humanize.IBytes(pktSize), src,
+ )
+ },
+ )
+ return err
+ }
+ dstRaw, err := ioutil.ReadAll(pipeR)
+ if err != nil {
+ ctx.LogE("rx-read", les, err, func(les LEs) string {
+ return fmt.Sprintf(
+ "Tossing freq %s/%s (%s): %s: reading",
+ sender.Name, pktName,
+ humanize.IBytes(pktSize), src,
+ )
+ })
+ return err
+ }
+ dst := string(dstRaw)
+ les = append(les, LE{"Dst", dst})
+ freqPath := sender.FreqPath
+ if freqPath == nil {
+ err = errors.New("freqing is not allowed")
+ ctx.LogE(
+ "rx-no-freq", les, err,
+ func(les LEs) string {
+ return fmt.Sprintf(
+ "Tossing freq %s/%s (%s): %s -> %s",
+ sender.Name, pktName,
+ humanize.IBytes(pktSize), src, dst,
+ )
+ },
+ )
+ return err
+ }
+ if !dryRun {
+ err = ctx.TxFile(
+ sender,
+ pkt.Nice,
+ filepath.Join(*freqPath, src),
+ dst,
+ sender.FreqChunked,
+ sender.FreqMinSize,
+ sender.FreqMaxSize,
+ nil,
+ )
+ if err != nil {
+ ctx.LogE("rx-tx", les, err, func(les LEs) string {
+ return fmt.Sprintf(
+ "Tossing freq %s/%s (%s): %s -> %s: txing",
+ sender.Name, pktName,
+ humanize.IBytes(pktSize), src, dst,
+ )
+ })
+ return err
+ }
+ }
+ ctx.LogI("rx", les, func(les LEs) string {
+ return fmt.Sprintf("Got file request %s to %s", src, sender.Name)
+ })
+ if !dryRun {
+ if jobPath != "" {
+ if doSeen {
+ if err := ensureDir(filepath.Dir(jobPath), SeenDir); err != nil {
+ return err
+ }
+ if fd, err := os.Create(jobPath2Seen(jobPath)); err == nil {
+ fd.Close()
+ if err = DirSync(filepath.Dir(jobPath)); err != nil {
+ ctx.LogE("rx-dirsync", les, err, func(les LEs) string {
+ return fmt.Sprintf(
+ "Tossing file %s/%s (%s): %s: dirsyncing",
+ sender.Name, pktName,
+ humanize.IBytes(pktSize),
+ filepath.Base(jobPath),
+ )
+ })
+ return err