Refactor sync file reading
This commit is contained in:
parent
541e32e10b
commit
6ca71230c1
4 changed files with 74 additions and 62 deletions
|
|
@ -1,9 +1,9 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/base32"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
|
@ -87,10 +87,15 @@ func (t *imageImporterTransformer) Transform(doc *ast.Document, reader text.Read
|
|||
return ast.WalkStop, err
|
||||
} else {
|
||||
defer fdto.Close()
|
||||
writer := bufio.NewWriter(fdto)
|
||||
if err := GetFile(t.importer, path.Join(t.rootDir, iPath), writer); err != nil {
|
||||
|
||||
if fd, closer, err := GetFile(t.importer, path.Join(t.rootDir, iPath)); err != nil {
|
||||
os.Remove(dPath)
|
||||
return ast.WalkStop, err
|
||||
} else {
|
||||
defer closer()
|
||||
|
||||
_, err = io.Copy(fdto, fd)
|
||||
return ast.WalkStop, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue