/*
NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2022 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2023 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
package main
import (
+ "errors"
"flag"
"fmt"
"io"
+ "io/fs"
"log"
"os"
"path/filepath"
)
func usage() {
- fmt.Fprintf(os.Stderr, nncp.UsageHeader())
- fmt.Fprintf(os.Stderr, "nncp-rm -- remove packet\n\n")
+ fmt.Fprint(os.Stderr, "nncp-rm -- remove packet\n\n")
fmt.Fprintf(os.Stderr, "Usage: %s [options] [-older X] -tmp\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s [options] -lock\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s [options] [-older X] {-all|-node NODE} -part\n", os.Args[0])
}
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) {
+ if _, err := os.Stat(p); err != nil && errors.Is(err, fs.ErrNotExist) {
return nil
}
dir, err := os.Open(p)
if err != nil {
- if os.IsNotExist(err) {
+ if errors.Is(err, fs.ErrNotExist) {
return nil
}
return err
return err
}
if now.Sub(info.ModTime()) < oldBoundary {
- ctx.LogD("rm-skip", nncp.LEs{{K: "File", V: pth}}, func(les nncp.LEs) string {
- return fmt.Sprintf("File %s: too fresh, skipping", pth)
- })
+ ctx.LogD("rm-skip", nncp.LEs{{K: "File", V: pth}},
+ func(les nncp.LEs) string {
+ return fmt.Sprintf("File %s: too fresh, skipping", pth)
+ },
+ )
continue
}
if (*doNoCK && strings.HasSuffix(entry.Name(), nncp.NoCKSuffix)) ||
}
}
removeSub := func(p string) error {
- return filepath.Walk(p, func(path string, info os.FileInfo, err error) error {
+ return filepath.Walk(p, func(
+ path string, info os.FileInfo, err error,
+ ) error {
if err != nil {
- if os.IsNotExist(err) {
+ if errors.Is(err, fs.ErrNotExist) {
return nil
}
return err
filepath.Join(ctx.Spool, node.Id.String(), nncp.AreaDir),
func(path string, info os.FileInfo, err error) error {
if err != nil {
- if os.IsNotExist(err) {
+ if errors.Is(err, fs.ErrNotExist) {
return nil
}
return err