mirror of
https://github.com/kopia/kopia.git
synced 2026-05-16 18:54:38 -04:00
Trivial cleanup for internal diff (#316)
* Prefer filepath.Join * Remove downloadFile's receiver parameter
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user