mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 22:27:35 +00:00
Fix ineffassign mistakes
This commit is contained in:
parent
4640d1a28e
commit
971ecee171
18
build.go
18
build.go
@ -125,6 +125,7 @@ func copyFile(dst, src string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fsrc.Close()
|
||||
|
||||
if err = os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
|
||||
fmt.Printf("MkdirAll(%v)\n", filepath.Dir(dst))
|
||||
@ -135,28 +136,17 @@ func copyFile(dst, src string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fdst.Close()
|
||||
|
||||
if _, err = io.Copy(fdst, fsrc); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
err = fsrc.Close()
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
err = fdst.Close()
|
||||
}
|
||||
|
||||
_, err = io.Copy(fdst, fsrc)
|
||||
if err == nil {
|
||||
err = os.Chmod(dst, fi.Mode())
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
err = os.Chtimes(dst, fi.ModTime(), fi.ModTime())
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// die prints the message with fmt.Fprintf() to stderr and exits with an error
|
||||
|
@ -559,7 +559,7 @@ func TestBackupExclude(t *testing.T) {
|
||||
|
||||
opts.Excludes = []string{"*.tar.gz", "private/secret"}
|
||||
testRunBackup(t, []string{datadir}, opts, gopts)
|
||||
snapshots, snapshotID = lastSnapshot(snapshots, loadSnapshotMap(t, gopts))
|
||||
_, snapshotID = lastSnapshot(snapshots, loadSnapshotMap(t, gopts))
|
||||
files = testRunLs(t, gopts, snapshotID)
|
||||
Assert(t, !includes(files, filepath.Join(string(filepath.Separator), "testdata", "foo.tar.gz")),
|
||||
"expected file %q not in first snapshot, but it's included", "foo.tar.gz")
|
||||
|
@ -212,6 +212,10 @@ func TestApplyPolicy(t *testing.T) {
|
||||
|
||||
var want restic.Snapshots
|
||||
err = json.Unmarshal(buf, &want)
|
||||
if err != nil {
|
||||
t.Errorf("error unmarshalling golden file %v: %v", goldenFilename, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(keep, want) {
|
||||
t.Errorf("test %v: wrong result, want:\n %v\ngot:\n %v", i, want, keep)
|
||||
|
Loading…
Reference in New Issue
Block a user