mirror of https://github.com/restic/restic.git
Merge pull request #3402 from MichaelEischer/misc-fixes
Various small code cleanups
This commit is contained in:
commit
fdbd65485e
|
@ -40,8 +40,6 @@ Exit status is 0 if the command was successful, and non-zero if there was any er
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const shortStr = 8 // Length of short IDs: 4 bytes as hex strings
|
|
||||||
|
|
||||||
// FindOptions bundles all options for the find command.
|
// FindOptions bundles all options for the find command.
|
||||||
type FindOptions struct {
|
type FindOptions struct {
|
||||||
Oldest string
|
Oldest string
|
||||||
|
@ -386,12 +384,12 @@ func (f *Finder) findIDs(ctx context.Context, sn *restic.Snapshot) error {
|
||||||
idStr := id.String()
|
idStr := id.String()
|
||||||
if _, ok := f.blobIDs[idStr]; !ok {
|
if _, ok := f.blobIDs[idStr]; !ok {
|
||||||
// Look for short ID form
|
// Look for short ID form
|
||||||
if _, ok := f.blobIDs[idStr[:shortStr]]; !ok {
|
if _, ok := f.blobIDs[id.Str()]; !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Replace the short ID with the long one
|
// Replace the short ID with the long one
|
||||||
f.blobIDs[idStr] = struct{}{}
|
f.blobIDs[idStr] = struct{}{}
|
||||||
delete(f.blobIDs, idStr[:shortStr])
|
delete(f.blobIDs, id.Str())
|
||||||
}
|
}
|
||||||
f.out.PrintObject("blob", idStr, nodepath, parentTreeID.String(), sn)
|
f.out.PrintObject("blob", idStr, nodepath, parentTreeID.String(), sn)
|
||||||
}
|
}
|
||||||
|
@ -423,7 +421,7 @@ func (f *Finder) packsToBlobs(ctx context.Context, packs []string) error {
|
||||||
idStr := id.String()
|
idStr := id.String()
|
||||||
if _, ok := packIDs[idStr]; !ok {
|
if _, ok := packIDs[idStr]; !ok {
|
||||||
// Look for short ID form
|
// Look for short ID form
|
||||||
if _, ok := packIDs[idStr[:shortStr]]; !ok {
|
if _, ok := packIDs[id.Str()]; !ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ type Config struct {
|
||||||
Container string
|
Container string
|
||||||
Prefix string
|
Prefix string
|
||||||
|
|
||||||
Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 20)"`
|
Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfig returns a new Config with the default values filled in.
|
// NewConfig returns a new Config with the default values filled in.
|
||||||
|
|
|
@ -16,7 +16,7 @@ type Config struct {
|
||||||
Bucket string
|
Bucket string
|
||||||
Prefix string
|
Prefix string
|
||||||
|
|
||||||
Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 20)"`
|
Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfig returns a new Config with the default values filled in.
|
// NewConfig returns a new Config with the default values filled in.
|
||||||
|
|
|
@ -35,10 +35,9 @@ func ReadAt(ctx context.Context, be Backend, h Handle, offset int64, p []byte) (
|
||||||
return ierr
|
return ierr
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, errors.Wrapf(err, "ReadFull(%v)", h)
|
||||||
}
|
}
|
||||||
|
|
||||||
debug.Log("ReadAt(%v) ReadFull returned %v bytes", h, n)
|
debug.Log("ReadAt(%v) ReadFull returned %v bytes", h, n)
|
||||||
|
return n, nil
|
||||||
return n, errors.Wrapf(err, "ReadFull(%v)", h)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue