fix comment and variable name typos

This commit is contained in:
Michael Eischer committed 2026-05-16 17:05:33 +02:00
1 parent fa1a318780
commit 10645ccd2a
17 files changed
+34 -30

No files matched your search

+2 -2
View File
@@ -163,7 +163,7 @@ func (s *statefulOutput) PrintPatternJSON(path string, node *data.Node) {
findNode: (*findNode)(node), findNode: (*findNode)(node),
}) })
if err != nil { if err != nil {
s.printer.E("Marshall failed: %v", err) s.printer.E("Marshal failed: %v", err)
return return
} }
if !s.inuse { if !s.inuse {
@@ -222,7 +222,7 @@ func (s *statefulOutput) PrintObjectJSON(kind, id, nodepath, treeID string, sn *
Time: sn.Time, Time: sn.Time,
}) })
if err != nil { if err != nil {
s.printer.E("Marshall failed: %v", err) s.printer.E("Marshal failed: %v", err)
return return
} }
if !s.inuse { if !s.inuse {
+2 -2
View File
@@ -11,7 +11,7 @@ import (
) )
// initMultiSnapshotFilter is used for commands that work on multiple snapshots // initMultiSnapshotFilter is used for commands that work on multiple snapshots
// MUST be combined with restic.FindFilteredSnapshots or FindFilteredSnapshots // MUST be combined with FindFilteredSnapshots
// MUST be followed by finalizeSnapshotFilter after flag parsing // MUST be followed by finalizeSnapshotFilter after flag parsing
func initMultiSnapshotFilter(flags *pflag.FlagSet, filt *data.SnapshotFilter, addHostShorthand bool) { func initMultiSnapshotFilter(flags *pflag.FlagSet, filt *data.SnapshotFilter, addHostShorthand bool) {
hostShorthand := "H" hostShorthand := "H"
@@ -24,7 +24,7 @@ func initMultiSnapshotFilter(flags *pflag.FlagSet, filt *data.SnapshotFilter, ad
} }
// initSingleSnapshotFilter is used for commands that work on a single snapshot // initSingleSnapshotFilter is used for commands that work on a single snapshot
// MUST be combined with restic.FindFilteredSnapshot // MUST be combined with (*data.SnapshotFilter).FindLatest
// MUST be followed by finalizeSnapshotFilter after flag parsing // MUST be followed by finalizeSnapshotFilter after flag parsing
func initSingleSnapshotFilter(flags *pflag.FlagSet, filt *data.SnapshotFilter) { func initSingleSnapshotFilter(flags *pflag.FlagSet, filt *data.SnapshotFilter) {
flags.StringArrayVarP(&filt.Hosts, "host", "H", nil, "only consider snapshots for this `host`, when snapshot ID \"latest\" is given (can be specified multiple times, use empty string to unset default value) (default: $RESTIC_HOST)") flags.StringArrayVarP(&filt.Hosts, "host", "H", nil, "only consider snapshots for this `host`, when snapshot ID \"latest\" is given (can be specified multiple times, use empty string to unset default value) (default: $RESTIC_HOST)")
+1 -1
View File
@@ -162,7 +162,7 @@ func (o Options) ApplyDefaults() Options {
if o.SaveTreeConcurrency == 0 { if o.SaveTreeConcurrency == 0 {
// can either wait for a file, wait for a tree, serialize a tree or wait for saveblob // can either wait for a file, wait for a tree, serialize a tree or wait for saveblob
// the last two are cpu-bound and thus mutually exclusive. // the last two are cpu-bound and thus mutually exclusive.
// Also allow waiting for FileReadConcurrency files, this is the maximum of files // Also allow waiting for ReadConcurrency files, this is the maximum of files
// which currently can be in progress. The main backup loop blocks when trying to queue // which currently can be in progress. The main backup loop blocks when trying to queue
// more files to read. // more files to read.
o.SaveTreeConcurrency = uint(runtime.GOMAXPROCS(0)) + o.ReadConcurrency o.SaveTreeConcurrency = uint(runtime.GOMAXPROCS(0)) + o.ReadConcurrency
+1 -1
View File
@@ -214,7 +214,7 @@ func newDeviceMap(allowedSourcePaths []string, fs fs.FS) (deviceMap, error) {
return deviceMap, nil return deviceMap, nil
} }
// IsAllowed returns true if the path is located on an allowed device. // IsAllowed reports whether the path is located on an allowed device.
func (m deviceMap) IsAllowed(item string, deviceID uint64, fs fs.FS) (bool, error) { func (m deviceMap) IsAllowed(item string, deviceID uint64, fs fs.FS) (bool, error) {
for dir := item; ; dir = fs.Dir(dir) { for dir := item; ; dir = fs.Dir(dir) {
debug.Log("item %v, test dir %v", item, dir) debug.Log("item %v, test dir %v", item, dir)
+2 -2
View File
@@ -138,7 +138,7 @@ func (sn *Snapshot) fillUserInfo() error {
return err return err
} }
// AddTags adds the given tags to the snapshots tags, preventing duplicates. // AddTags adds the given tags to the snapshot's tags, preventing duplicates.
// It returns true if any changes were made. // It returns true if any changes were made.
func (sn *Snapshot) AddTags(addTags []string) (changed bool) { func (sn *Snapshot) AddTags(addTags []string) (changed bool) {
nextTag: nextTag:
@@ -154,7 +154,7 @@ nextTag:
return return
} }
// RemoveTags removes the given tags from the snapshots tags and // RemoveTags removes the given tags from the snapshot's tags and
// returns true if any changes were made. // returns true if any changes were made.
func (sn *Snapshot) RemoveTags(removeTags []string) (changed bool) { func (sn *Snapshot) RemoveTags(removeTags []string) (changed bool) {
for _, remove := range removeTags { for _, remove := range removeTags {
+3 -3
View File
@@ -1,5 +1,5 @@
// Package filter implements filters for files similar to filepath.Glob, but // Package filter implements path filters similar to filepath.Match, but
// in contrast to filepath.Glob a pattern may specify directories. // patterns may span multiple path components and use a recursive "**" wildcard.
// //
// For a list of valid patterns please see the documentation on filepath.Glob. // Single-component wildcards follow filepath.Match rules; see Match for details.
package filter package filter
+11 -7
View File
@@ -7,8 +7,8 @@ import (
"github.com/restic/restic/internal/errors" "github.com/restic/restic/internal/errors"
) )
// ErrBadString is returned when Match is called with the empty string as the // ErrBadString is returned when an empty path string is passed to prepareStr
// second argument. // (used by Match, ChildMatch, List, and ListWithChild).
var ErrBadString = errors.New("filter.Match: string is empty") var ErrBadString = errors.New("filter.Match: string is empty")
type patternPart struct { type patternPart struct {
@@ -65,9 +65,10 @@ func splitPath(p string) []string {
return parts return parts
} }
// Match returns true if str matches the pattern. When the pattern is // Match reports whether str matches the pattern. When the pattern is
// malformed, filepath.ErrBadPattern is returned. The empty pattern matches // malformed, filepath.ErrBadPattern is returned. The empty pattern matches
// everything, when str is the empty string ErrBadString is returned. // everything, when str is the empty string ErrBadString is returned.
// Patterns prefixed with "!" are not supported; use List or ListWithChild.
// //
// Pattern can be a combination of patterns suitable for filepath.Match, joined // Pattern can be a combination of patterns suitable for filepath.Match, joined
// by filepath.Separator. // by filepath.Separator.
@@ -90,9 +91,10 @@ func Match(patternStr, str string) (matched bool, err error) {
return match(pattern, strs) return match(pattern, strs)
} }
// ChildMatch returns true if children of str can match the pattern. When the pattern is // ChildMatch reports whether children of str can match the pattern. When the pattern is
// malformed, filepath.ErrBadPattern is returned. The empty pattern matches // malformed, filepath.ErrBadPattern is returned. The empty pattern matches
// everything, when str is the empty string ErrBadString is returned. // everything, when str is the empty string ErrBadString is returned.
// Patterns prefixed with "!" are not supported; use List or ListWithChild.
// //
// Pattern can be a combination of patterns suitable for filepath.Match, joined // Pattern can be a combination of patterns suitable for filepath.Match, joined
// by filepath.Separator. // by filepath.Separator.
@@ -266,18 +268,20 @@ func ParsePatterns(pattern []string) []Pattern {
return patpat return patpat
} }
// List returns true if str matches one of the patterns. Empty patterns are ignored. // List reports whether str matches one of the patterns. Empty patterns are ignored.
func List(patterns []Pattern, str string) (matched bool, err error) { func List(patterns []Pattern, str string) (matched bool, err error) {
matched, _, err = list(patterns, false, str) matched, _, err = list(patterns, false, str)
return matched, err return matched, err
} }
// ListWithChild returns true if str matches one of the patterns. Empty patterns are ignored. // ListWithChild reports whether str matches one of the patterns and whether child
// paths might still match. Empty patterns are ignored.
func ListWithChild(patterns []Pattern, str string) (matched bool, childMayMatch bool, err error) { func ListWithChild(patterns []Pattern, str string) (matched bool, childMayMatch bool, err error) {
return list(patterns, true, str) return list(patterns, true, str)
} }
// list returns true if str matches one of the patterns. Empty patterns are ignored. // list reports whether str matches one of the patterns and, when checkChildMatches is
// true, whether child paths might still match. Empty patterns are ignored.
// Patterns prefixed by "!" are negated: any matching file excluded by a previous pattern // Patterns prefixed by "!" are negated: any matching file excluded by a previous pattern
// will become included again. // will become included again.
func list(patterns []Pattern, checkChildMatches bool, str string) (matched bool, childMayMatch bool, err error) { func list(patterns []Pattern, checkChildMatches bool, str string) (matched bool, childMayMatch bool, err error) {
+2 -2
View File
@@ -75,7 +75,7 @@ func (opts IncludePatternOptions) CollectPatterns(warnf func(msg string, args ..
return fs, nil return fs, nil
} }
// IncludeByPattern returns a IncludeByNameFunc which includes files that match // IncludeByPattern returns an IncludeByNameFunc which includes files that match
// one of the patterns. // one of the patterns.
func IncludeByPattern(patterns []string, warnf func(msg string, args ...interface{})) IncludeByNameFunc { func IncludeByPattern(patterns []string, warnf func(msg string, args ...interface{})) IncludeByNameFunc {
parsedPatterns := ParsePatterns(patterns) parsedPatterns := ParsePatterns(patterns)
@@ -89,7 +89,7 @@ func IncludeByPattern(patterns []string, warnf func(msg string, args ...interfac
} }
} }
// IncludeByInsensitivePattern returns a IncludeByNameFunc which includes files that match // IncludeByInsensitivePattern returns an IncludeByNameFunc which includes files that match
// one of the patterns, ignoring the casing of the filenames. // one of the patterns, ignoring the casing of the filenames.
func IncludeByInsensitivePattern(patterns []string, warnf func(msg string, args ...interface{})) IncludeByNameFunc { func IncludeByInsensitivePattern(patterns []string, warnf func(msg string, args ...interface{})) IncludeByNameFunc {
lowerPatterns := make([]string, len(patterns)) lowerPatterns := make([]string, len(patterns))
+1 -1
View File
@@ -160,7 +160,7 @@ func setFileEA(handle windows.Handle, iosb *ioStatusBlock, buf *uint8, bufLen ui
return return
} }
// pathSupportsExtendedAttributes returns true if the path supports extended attributes. // pathSupportsExtendedAttributes reports whether the path's volume supports extended attributes.
func pathSupportsExtendedAttributes(path string) (supported bool, err error) { func pathSupportsExtendedAttributes(path string) (supported bool, err error) {
var fileSystemFlags uint32 var fileSystemFlags uint32
utf16Path, err := windows.UTF16PtrFromString(path) utf16Path, err := windows.UTF16PtrFromString(path)
+1 -1
View File
@@ -49,7 +49,7 @@ type ErrorHandler func(item string, err error)
// MessageHandler is used to report errors/messages via callbacks. // MessageHandler is used to report errors/messages via callbacks.
type MessageHandler func(msg string, args ...interface{}) type MessageHandler func(msg string, args ...interface{})
// VolumeFilter is used to filter volumes by it's mount point or GUID path. // VolumeFilter is used to filter volumes by their mount point or GUID path.
type VolumeFilter func(volume string) bool type VolumeFilter func(volume string) bool
// LocalVss is a wrapper around the local file system which uses windows volume // LocalVss is a wrapper around the local file system which uses windows volume
+1 -1
View File
@@ -292,7 +292,7 @@ func fixEncryptionAttribute(path string, attrs *uint32, pathPointer *uint16) (er
return fmt.Errorf("failed to get file attributes for existing file: %s : %v", path, err) return fmt.Errorf("failed to get file attributes for existing file: %s : %v", path, err)
} }
if existingAttrs&windows.FILE_ATTRIBUTE_ENCRYPTED != 0 { if existingAttrs&windows.FILE_ATTRIBUTE_ENCRYPTED != 0 {
// File should not be encrypted, but its already encrypted. Decrypt it. // File should not be encrypted, but it's already encrypted. Decrypt it.
err = decryptFile(pathPointer) err = decryptFile(pathPointer)
if err != nil { if err != nil {
if IsAccessDenied(err) || errors.Is(err, windows.ERROR_FILE_READ_ONLY) { if IsAccessDenied(err) || errors.Is(err, windows.ERROR_FILE_READ_ONLY) {
+1 -1
View File
@@ -27,7 +27,7 @@ type VssSnapshot struct {
mountPointInfo map[string]MountPoint mountPointInfo map[string]MountPoint
} }
// HasSufficientPrivilegesForVSS returns true if the user is allowed to use VSS. // HasSufficientPrivilegesForVSS returns nil if the user is allowed to use VSS.
func HasSufficientPrivilegesForVSS() error { func HasSufficientPrivilegesForVSS() error {
return errors.New("VSS snapshots are only supported on windows") return errors.New("VSS snapshots are only supported on windows")
} }
+1 -1
View File
@@ -1244,7 +1244,7 @@ func queryInterface(oleIUnknown *ole.IUnknown, guid *ole.GUID) (*interface{}, er
return ivss, nil return ivss, nil
} }
// isRunningOn64BitWindows returns true if running on 64-bit windows. // isRunningOn64BitWindows reports whether the process is running on 64-bit Windows.
func isRunningOn64BitWindows() (bool, error) { func isRunningOn64BitWindows() (bool, error) {
if runtime.GOARCH == "amd64" { if runtime.GOARCH == "amd64" {
return true, nil return true, nil
+1 -1
View File
@@ -101,7 +101,7 @@ func (opts *SecondaryRepoOptions) FillGlobalOpts(ctx context.Context, gopts Opti
dstGopts.PasswordFile = opts.LegacyPasswordFile dstGopts.PasswordFile = opts.LegacyPasswordFile
dstGopts.PasswordCommand = opts.LegacyPasswordCommand dstGopts.PasswordCommand = opts.LegacyPasswordCommand
dstGopts.KeyHint = opts.LegacyKeyHint dstGopts.KeyHint = opts.LegacyKeyHint
// keep existing bevhaior for legacy options // keep existing behavior for legacy options
dstGopts.InsecureNoPassword = false dstGopts.InsecureNoPassword = false
pwdEnv = "RESTIC_PASSWORD2" pwdEnv = "RESTIC_PASSWORD2"
+1 -1
View File
@@ -9,7 +9,7 @@ type HardlinkKey struct {
Inode, Device uint64 Inode, Device uint64
} }
// HardlinkIndex contains a list of inodes, devices these inodes are one, and associated file names. // HardlinkIndex maps inodes on devices to associated values.
type HardlinkIndex[T any] struct { type HardlinkIndex[T any] struct {
m sync.Mutex m sync.Mutex
Index map[HardlinkKey]T Index map[HardlinkKey]T
+2 -2
View File
@@ -66,7 +66,7 @@ func NewTreeRewriter(opts RewriteOpts) *TreeRewriter {
return rw return rw
} }
func NewSnapshotSizeRewriter(rewriteNode NodeRewriteFunc, keepEmptyDirecoryFilter NodeKeepEmptyDirectoryFunc) (*TreeRewriter, QueryRewrittenSizeFunc) { func NewSnapshotSizeRewriter(rewriteNode NodeRewriteFunc, keepEmptyDirectoryFilter NodeKeepEmptyDirectoryFunc) (*TreeRewriter, QueryRewrittenSizeFunc) {
var count uint var count uint
var size uint64 var size uint64
@@ -80,7 +80,7 @@ func NewSnapshotSizeRewriter(rewriteNode NodeRewriteFunc, keepEmptyDirecoryFilte
return node return node
}, },
DisableNodeCache: true, DisableNodeCache: true,
KeepEmptyDirectory: keepEmptyDirecoryFilter, KeepEmptyDirectory: keepEmptyDirectoryFilter,
}) })
ss := func() SnapshotSize { ss := func() SnapshotSize {
+1 -1
View File
@@ -15,7 +15,7 @@ var ErrSkipNode = errors.New("skip this node")
// WalkFunc is the type of the function called for each node visited by Walk. // WalkFunc is the type of the function called for each node visited by Walk.
// Path is the slash-separated path from the root node. If there was a problem // Path is the slash-separated path from the root node. If there was a problem
// loading a node, err is set to a non-nil error. WalkFunc can chose to ignore // loading a node, err is set to a non-nil error. WalkFunc can choose to ignore
// it by returning nil. // it by returning nil.
// //
// When the special value ErrSkipNode is returned and node is a dir node, it is // When the special value ErrSkipNode is returned and node is a dir node, it is