- remove := func(xx nncp.TRxTx) error {
- return filepath.Walk(
- filepath.Join(ctx.Spool, node.Id.String(), string(xx)),
- func(path string, info os.FileInfo, err error) error {
- if err != nil {
- return err
- }
- if info.IsDir() {
+ for _, node := range ctx.Neigh {
+ if nodeId != nil && node.Id != nodeId {
+ continue
+ }
+ remove := func(xx nncp.TRxTx) error {
+ p := filepath.Join(ctx.Spool, node.Id.String(), string(xx))
+ if _, err := os.Stat(p); err != nil && os.IsNotExist(err) {
+ return nil
+ }
+ return filepath.Walk(p,
+ func(path string, info os.FileInfo, err error) error {
+ if err != nil {
+ return err
+ }
+ if info.IsDir() {
+ return nil
+ }
+ logMsg := func(les nncp.LEs) string {
+ return fmt.Sprintf("File %s: removed", path)
+ }
+ if now.Sub(info.ModTime()) < oldBoundary {
+ ctx.LogD("rm-skip", nncp.LEs{{K: "File", V: path}}, func(les nncp.LEs) string {
+ return fmt.Sprintf("File %s: too fresh, skipping", path)
+ })
+ return nil
+ }
+ if (*doNoCK && strings.HasSuffix(info.Name(), nncp.NoCKSuffix)) ||
+ (*doPart && strings.HasSuffix(info.Name(), nncp.PartSuffix)) {
+ ctx.LogI("rm", nncp.LEs{{K: "File", V: path}}, logMsg)
+ if *dryRun {
+ return nil
+ }
+ return os.Remove(path)
+ }
+ if len(pkts) > 0 {
+ if _, exists := pkts[filepath.Base(info.Name())]; exists {
+ ctx.LogI("rm", nncp.LEs{{K: "File", V: path}}, logMsg)
+ if *dryRun {
+ return nil
+ }
+ return os.Remove(path)
+ }
+ }
+ if !*doSeen && !*doNoCK && !*doHdr && !*doPart &&
+ (*doRx || *doTx) &&
+ ((*doRx && xx == nncp.TRx) || (*doTx && xx == nncp.TTx)) {
+ ctx.LogI("rm", nncp.LEs{{K: "File", V: path}}, logMsg)
+ if *dryRun {
+ return nil
+ }
+ return os.Remove(path)
+ }