Trivial cleanup for internal diff (#316)

* Prefer filepath.Join
* Remove downloadFile's receiver parameter
This commit is contained in:
Julio López
2020-03-09 18:18:42 -07:00
committed by GitHub
parent 3ebef0ada9
commit 88ce341a40

View File

@@ -230,10 +230,10 @@ func (c *Comparer) compareFiles(ctx context.Context, f1, f2 fs.File, fname strin
newName := "/dev/null"
if f1 != nil {
oldName = filepath.Clean("old/" + fname)
oldName = filepath.Join("old", fname)
oldFile := filepath.Join(c.tmpDir, oldName)
if err := c.downloadFile(ctx, f1, oldFile); err != nil {
if err := downloadFile(ctx, f1, oldFile); err != nil {
return errors.Wrap(err, "error downloading old file")
}
@@ -241,10 +241,10 @@ func (c *Comparer) compareFiles(ctx context.Context, f1, f2 fs.File, fname strin
}
if f2 != nil {
newName = filepath.Clean("new/" + fname)
newName = filepath.Join("new", fname)
newFile := filepath.Join(c.tmpDir, newName)
if err := c.downloadFile(ctx, f2, newFile); err != nil {
if err := downloadFile(ctx, f2, newFile); err != nil {
return errors.Wrap(err, "error downloading new file")
}
defer os.Remove(newFile) //nolint:errcheck
@@ -263,7 +263,7 @@ func (c *Comparer) compareFiles(ctx context.Context, f1, f2 fs.File, fname strin
return nil
}
func (c *Comparer) downloadFile(ctx context.Context, f fs.File, fname string) error {
func downloadFile(ctx context.Context, f fs.File, fname string) error {
if err := os.MkdirAll(filepath.Dir(fname), 0700); err != nil {
return err
}