X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcmd%2Fnncp-rm%2Fmain.go;h=b1d15249047251dc183f9934fafaa345c8e4c046;hb=83d7a84ab525029706b7eb6674c672626cf9793e;hp=ef6c44d287f7e27e38b2488997b742e004b0925c;hpb=b6f19d6d9bad1d7d501253a158cf80dc37c43025;p=nncp.git diff --git a/src/cmd/nncp-rm/main.go b/src/cmd/nncp-rm/main.go index ef6c44d..b1d1524 100644 --- a/src/cmd/nncp-rm/main.go +++ b/src/cmd/nncp-rm/main.go @@ -1,6 +1,6 @@ /* NNCP -- Node to Node copy, utilities for store-and-forward data exchange -Copyright (C) 2016-2022 Sergey Matveev +Copyright (C) 2016-2023 Sergey Matveev 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 @@ -19,9 +19,11 @@ along with this program. If not, see . package main import ( + "errors" "flag" "fmt" "io" + "io/fs" "log" "os" "path/filepath" @@ -34,8 +36,7 @@ import ( ) 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]) @@ -205,12 +206,12 @@ func main() { } 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 @@ -249,9 +250,11 @@ func main() { 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)) || @@ -291,9 +294,11 @@ func main() { } } 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 @@ -356,7 +361,7 @@ func main() { 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