sync: Return the reader from importer instead of writing to a given Writer

This commit is contained in:
nemunaire 2022-11-21 12:30:13 +01:00
commit 541e32e10b
4 changed files with 34 additions and 26 deletions

View file

@ -1,7 +1,6 @@
package sync
import (
"bufio"
"fmt"
"io"
"io/ioutil"
@ -81,15 +80,11 @@ func (i LocalImporter) importFile(URI string, next func(string, string) (interfa
}
}
func (i LocalImporter) getFile(filename string, writer *bufio.Writer) error {
func (i LocalImporter) getFile(filename string) (io.Reader, error) {
if fd, err := os.Open(path.Join(i.Base, filename)); err != nil {
return err
return nil, err
} else {
defer fd.Close()
reader := bufio.NewReader(fd)
reader.WriteTo(writer)
writer.Flush()
return nil
return fd, nil
}
}