mirror of
https://github.com/restic/restic.git
synced 2025-08-22 02:51:05 +00:00
Fix linter errors (except for tests)
This commit is contained in:
@@ -147,8 +147,8 @@ func (o Options) ApplyDefaults() Options {
|
||||
func New(repo restic.Repository, fs fs.FS, opts Options) *Archiver {
|
||||
arch := &Archiver{
|
||||
Repo: repo,
|
||||
SelectByName: func(item string) bool { return true },
|
||||
Select: func(item string, fi os.FileInfo) bool { return true },
|
||||
SelectByName: func(_ string) bool { return true },
|
||||
Select: func(_ string, _ os.FileInfo) bool { return true },
|
||||
FS: fs,
|
||||
Options: opts.ApplyDefaults(),
|
||||
|
||||
@@ -762,7 +762,7 @@ func (arch *Archiver) Snapshot(ctx context.Context, targets []string, opts Snaps
|
||||
arch.runWorkers(wgCtx, wg)
|
||||
|
||||
debug.Log("starting snapshot")
|
||||
fn, nodeCount, err := arch.SaveTree(wgCtx, "/", atree, arch.loadParentTree(wgCtx, opts.ParentSnapshot), func(n *restic.Node, is ItemStats) {
|
||||
fn, nodeCount, err := arch.SaveTree(wgCtx, "/", atree, arch.loadParentTree(wgCtx, opts.ParentSnapshot), func(_ *restic.Node, is ItemStats) {
|
||||
arch.CompleteItem("/", nil, nil, is, time.Since(start))
|
||||
})
|
||||
if err != nil {
|
||||
|
@@ -25,10 +25,10 @@ type Scanner struct {
|
||||
func NewScanner(fs fs.FS) *Scanner {
|
||||
return &Scanner{
|
||||
FS: fs,
|
||||
SelectByName: func(item string) bool { return true },
|
||||
Select: func(item string, fi os.FileInfo) bool { return true },
|
||||
Error: func(item string, err error) error { return err },
|
||||
Result: func(item string, s ScanStats) {},
|
||||
SelectByName: func(_ string) bool { return true },
|
||||
Select: func(_ string, _ os.FileInfo) bool { return true },
|
||||
Error: func(_ string, err error) error { return err },
|
||||
Result: func(_ string, _ ScanStats) {},
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ func NewFactory() location.Factory {
|
||||
|
||||
return location.NewHTTPBackendFactory[struct{}, *MemoryBackend](
|
||||
"mem",
|
||||
func(s string) (*struct{}, error) {
|
||||
func(_ string) (*struct{}, error) {
|
||||
return &struct{}{}, nil
|
||||
},
|
||||
location.NoPassword,
|
||||
|
@@ -183,7 +183,7 @@ func newBackend(ctx context.Context, cfg Config, lim limiter.Limiter) (*Backend,
|
||||
dialCount := 0
|
||||
tr := &http2.Transport{
|
||||
AllowHTTP: true, // this is not really HTTP, just stdin/stdout
|
||||
DialTLS: func(network, address string, cfg *tls.Config) (net.Conn, error) {
|
||||
DialTLS: func(network, address string, _ *tls.Config) (net.Conn, error) {
|
||||
debug.Log("new connection requested, %v %v", network, address)
|
||||
if dialCount > 0 {
|
||||
// the connection to the child process is already closed
|
||||
|
@@ -134,7 +134,7 @@ func (c *Checker) LoadIndex(ctx context.Context, p *progress.Counter) (hints []e
|
||||
|
||||
if p != nil {
|
||||
var numIndexFiles uint64
|
||||
err := indexList.List(ctx, restic.IndexFile, func(id restic.ID, size int64) error {
|
||||
err := indexList.List(ctx, restic.IndexFile, func(_ restic.ID, _ int64) error {
|
||||
numIndexFiles++
|
||||
return nil
|
||||
})
|
||||
|
@@ -41,7 +41,7 @@ type trackFile struct {
|
||||
|
||||
func newTrackFile(stack []byte, filename string, file File) *trackFile {
|
||||
f := &trackFile{file}
|
||||
runtime.SetFinalizer(f, func(f *trackFile) {
|
||||
runtime.SetFinalizer(f, func(_ *trackFile) {
|
||||
fmt.Fprintf(os.Stderr, "file %s not closed\n\nStacktrack:\n%s\n", filename, stack)
|
||||
panic("file " + filename + " not closed")
|
||||
})
|
||||
|
@@ -295,7 +295,7 @@ func (d *SnapshotsDirStructure) updateSnapshots(ctx context.Context) error {
|
||||
}
|
||||
|
||||
var snapshots restic.Snapshots
|
||||
err := d.root.cfg.Filter.FindAll(ctx, d.root.repo, d.root.repo, nil, func(id string, sn *restic.Snapshot, err error) error {
|
||||
err := d.root.cfg.Filter.FindAll(ctx, d.root.repo, d.root.repo, nil, func(_ string, sn *restic.Snapshot, _ error) error {
|
||||
if sn != nil {
|
||||
snapshots = append(snapshots, sn)
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ func ForAllIndexes(ctx context.Context, lister restic.Lister, repo restic.Lister
|
||||
workerCount := repo.Connections() + uint(runtime.GOMAXPROCS(0))
|
||||
|
||||
var m sync.Mutex
|
||||
return restic.ParallelList(ctx, lister, restic.IndexFile, workerCount, func(ctx context.Context, id restic.ID, size int64) error {
|
||||
return restic.ParallelList(ctx, lister, restic.IndexFile, workerCount, func(ctx context.Context, id restic.ID, _ int64) error {
|
||||
var err error
|
||||
var idx *Index
|
||||
oldFormat := false
|
||||
|
@@ -136,7 +136,7 @@ func SearchKey(ctx context.Context, s *Repository, password string, maxKeys int,
|
||||
defer cancel()
|
||||
|
||||
// try at most maxKeys keys in repo
|
||||
err = s.List(listCtx, restic.KeyFile, func(id restic.ID, size int64) error {
|
||||
err = s.List(listCtx, restic.KeyFile, func(id restic.ID, _ int64) error {
|
||||
checked++
|
||||
if maxKeys > 0 && checked > maxKeys {
|
||||
return ErrMaxKeysReached
|
||||
|
@@ -68,7 +68,7 @@ func RepairPacks(ctx context.Context, repo restic.Repository, ids restic.IDSet,
|
||||
DeleteProgress: func() *progress.Counter {
|
||||
return printer.NewCounter("old indexes deleted")
|
||||
},
|
||||
DeleteReport: func(id restic.ID, err error) {
|
||||
DeleteReport: func(id restic.ID, _ error) {
|
||||
printer.VV("removed index %v", id.String())
|
||||
},
|
||||
})
|
||||
|
@@ -651,7 +651,7 @@ func (r *Repository) LoadIndex(ctx context.Context, p *progress.Counter) error {
|
||||
|
||||
if p != nil {
|
||||
var numIndexFiles uint64
|
||||
err := indexList.List(ctx, restic.IndexFile, func(id restic.ID, size int64) error {
|
||||
err := indexList.List(ctx, restic.IndexFile, func(_ restic.ID, _ int64) error {
|
||||
numIndexFiles++
|
||||
return nil
|
||||
})
|
||||
@@ -662,7 +662,7 @@ func (r *Repository) LoadIndex(ctx context.Context, p *progress.Counter) error {
|
||||
defer p.Done()
|
||||
}
|
||||
|
||||
err = index.ForAllIndexes(ctx, indexList, r, func(id restic.ID, idx *index.Index, oldFormat bool, err error) error {
|
||||
err = index.ForAllIndexes(ctx, indexList, r, func(_ restic.ID, idx *index.Index, _ bool, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ func Find(ctx context.Context, be Lister, t FileType, prefix string) (ID, error)
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
err := be.List(ctx, t, func(id ID, size int64) error {
|
||||
err := be.List(ctx, t, func(id ID, _ int64) error {
|
||||
name := id.String()
|
||||
if len(name) >= len(prefix) && prefix == name[:len(prefix)] {
|
||||
if match.IsNull() {
|
||||
|
@@ -341,7 +341,7 @@ func (l *Lock) checkExistence(ctx context.Context) (bool, error) {
|
||||
|
||||
exists := false
|
||||
|
||||
err := l.repo.List(ctx, LockFile, func(id ID, size int64) error {
|
||||
err := l.repo.List(ctx, LockFile, func(id ID, _ int64) error {
|
||||
if id.Equal(*l.lockID) {
|
||||
exists = true
|
||||
}
|
||||
@@ -415,7 +415,7 @@ func RemoveStaleLocks(ctx context.Context, repo Repository) (uint, error) {
|
||||
// RemoveAllLocks removes all locks forcefully.
|
||||
func RemoveAllLocks(ctx context.Context, repo Repository) (uint, error) {
|
||||
var processed uint32
|
||||
err := ParallelList(ctx, repo, LockFile, repo.Connections(), func(ctx context.Context, id ID, size int64) error {
|
||||
err := ParallelList(ctx, repo, LockFile, repo.Connections(), func(ctx context.Context, id ID, _ int64) error {
|
||||
err := repo.Backend().Remove(ctx, backend.Handle{Type: LockFile, Name: id.String()})
|
||||
if err == nil {
|
||||
atomic.AddUint32(&processed, 1)
|
||||
|
@@ -83,7 +83,7 @@ func ForAllSnapshots(ctx context.Context, be Lister, loader LoaderUnpacked, excl
|
||||
var m sync.Mutex
|
||||
|
||||
// For most snapshots decoding is nearly for free, thus just assume were only limited by IO
|
||||
return ParallelList(ctx, be, SnapshotFile, loader.Connections(), func(ctx context.Context, id ID, size int64) error {
|
||||
return ParallelList(ctx, be, SnapshotFile, loader.Connections(), func(ctx context.Context, id ID, _ int64) error {
|
||||
if excludeIDs.Has(id) {
|
||||
return nil
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ type Restorer struct {
|
||||
SelectFilter func(item string, dstpath string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool)
|
||||
}
|
||||
|
||||
var restorerAbortOnAllErrors = func(location string, err error) error { return err }
|
||||
var restorerAbortOnAllErrors = func(_ string, err error) error { return err }
|
||||
|
||||
// NewRestorer creates a restorer preloaded with the content from the snapshot id.
|
||||
func NewRestorer(repo restic.Repository, sn *restic.Snapshot, sparse bool,
|
||||
@@ -239,7 +239,7 @@ func (res *Restorer) RestoreTo(ctx context.Context, dst string) error {
|
||||
|
||||
// first tree pass: create directories and collect all files to restore
|
||||
_, err = res.traverseTree(ctx, dst, string(filepath.Separator), *res.sn.Tree, treeVisitor{
|
||||
enterDir: func(node *restic.Node, target, location string) error {
|
||||
enterDir: func(_ *restic.Node, target, location string) error {
|
||||
debug.Log("first pass, enterDir: mkdir %q, leaveDir should restore metadata", location)
|
||||
if res.progress != nil {
|
||||
res.progress.AddFile(0)
|
||||
@@ -366,7 +366,7 @@ func (res *Restorer) VerifyFiles(ctx context.Context, dst string) (int, error) {
|
||||
defer close(work)
|
||||
|
||||
_, err := res.traverseTree(ctx, dst, string(filepath.Separator), *res.sn.Tree, treeVisitor{
|
||||
visitNode: func(node *restic.Node, target, location string) error {
|
||||
visitNode: func(node *restic.Node, target, _ string) error {
|
||||
if node.Type != "file" {
|
||||
return nil
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ func NewProgress(printer ProgressPrinter, interval time.Duration) *Progress {
|
||||
printer: printer,
|
||||
estimator: *newRateEstimator(time.Now()),
|
||||
}
|
||||
p.Updater = *progress.NewUpdater(interval, func(runtime time.Duration, final bool) {
|
||||
p.Updater = *progress.NewUpdater(interval, func(_ time.Duration, final bool) {
|
||||
if final {
|
||||
p.printer.Reset()
|
||||
} else {
|
||||
|
@@ -39,13 +39,13 @@ func NewTreeRewriter(opts RewriteOpts) *TreeRewriter {
|
||||
}
|
||||
// setup default implementations
|
||||
if rw.opts.RewriteNode == nil {
|
||||
rw.opts.RewriteNode = func(node *restic.Node, path string) *restic.Node {
|
||||
rw.opts.RewriteNode = func(node *restic.Node, _ string) *restic.Node {
|
||||
return node
|
||||
}
|
||||
}
|
||||
if rw.opts.RewriteFailedTree == nil {
|
||||
// fail with error by default
|
||||
rw.opts.RewriteFailedTree = func(nodeID restic.ID, path string, err error) (restic.ID, error) {
|
||||
rw.opts.RewriteFailedTree = func(_ restic.ID, _ string, err error) (restic.ID, error) {
|
||||
return restic.ID{}, err
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user