forked from TrueCloudLab/restic
Fix issues reported by semgrep
This commit is contained in:
parent
7facc8ccc1
commit
36c5d39c2c
5 changed files with 6 additions and 26 deletions
|
@ -141,9 +141,7 @@ func TestUploadLargeFile(t *testing.T) {
|
||||||
|
|
||||||
azcfg, err := azure.ParseConfig(os.Getenv("RESTIC_TEST_AZURE_REPOSITORY"))
|
azcfg, err := azure.ParseConfig(os.Getenv("RESTIC_TEST_AZURE_REPOSITORY"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != nil {
|
t.Fatal(err)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := azcfg.(azure.Config)
|
cfg := azcfg.(azure.Config)
|
||||||
|
@ -158,9 +156,7 @@ func TestUploadLargeFile(t *testing.T) {
|
||||||
|
|
||||||
be, err := azure.Create(cfg, tr)
|
be, err := azure.Create(cfg, tr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != nil {
|
t.Fatal(err)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ func retry(max int, fail func(err error), f func() error) error {
|
||||||
for i := 0; i < max; i++ {
|
for i := 0; i < max; i++ {
|
||||||
err = f()
|
err = f()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
if fail != nil {
|
if fail != nil {
|
||||||
fail(err)
|
fail(err)
|
||||||
|
|
|
@ -517,12 +517,7 @@ func (r *Repository) LoadIndex(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove index files from the cache which have been removed in the repo
|
// remove index files from the cache which have been removed in the repo
|
||||||
err = r.PrepareCache(validIndex)
|
return r.PrepareCache(validIndex)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const listPackParallelism = 10
|
const listPackParallelism = 10
|
||||||
|
|
|
@ -351,12 +351,7 @@ func (res *Restorer) VerifyFiles(ctx context.Context, dst string) (int, error) {
|
||||||
offset += int64(length)
|
offset += int64(length)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = file.Close()
|
return file.Close()
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
leaveDir: func(node *restic.Node, target, location string) error { return nil },
|
leaveDir: func(node *restic.Node, target, location string) error { return nil },
|
||||||
})
|
})
|
||||||
|
|
|
@ -141,12 +141,6 @@ func saveSnapshot(t testing.TB, repo restic.Repository, snapshot Snapshot) (*res
|
||||||
return sn, id
|
return sn, id
|
||||||
}
|
}
|
||||||
|
|
||||||
// toSlash converts the OS specific path dir to a slash-separated path.
|
|
||||||
func toSlash(dir string) string {
|
|
||||||
data := strings.Split(dir, string(filepath.Separator))
|
|
||||||
return strings.Join(data, "/")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRestorer(t *testing.T) {
|
func TestRestorer(t *testing.T) {
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
Snapshot
|
Snapshot
|
||||||
|
@ -354,7 +348,7 @@ func TestRestorer(t *testing.T) {
|
||||||
|
|
||||||
errors := make(map[string]map[string]struct{})
|
errors := make(map[string]map[string]struct{})
|
||||||
res.Error = func(location string, err error) error {
|
res.Error = func(location string, err error) error {
|
||||||
location = toSlash(location)
|
location = filepath.ToSlash(location)
|
||||||
t.Logf("restore returned error for %q: %v", location, err)
|
t.Logf("restore returned error for %q: %v", location, err)
|
||||||
if errors[location] == nil {
|
if errors[location] == nil {
|
||||||
errors[location] = make(map[string]struct{})
|
errors[location] = make(map[string]struct{})
|
||||||
|
|
Loading…
Add table
Reference in a new issue