pagr

A 'static site generator', built using dati.
Log | Files | Refs | Atom

commit d4c2bc764343d813641b036ada485fbc1d78a8b9
parent 3743f009fc4e9afd58f1ff02164b9bdbc2b1eb7e
Author: gearsix <gearsix@tuta.io>
Date:   Sat, 22 Jan 2022 12:31:54 +0000

copyf is only called if src & dst name & size differ

Diffstat:
Mcopy.go | 17++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/copy.go b/copy.go @@ -70,14 +70,17 @@ func CopyFile(src, dst string) (err error) { if err = os.MkdirAll(filepath.Dir(dst), 0777); err != nil { return err } - - cSrc := C.CString(src) - cDst := C.CString(dst) - if uint32(C.copyf(cSrc, cDst)) != 0 { - err = fmt.Errorf("copyf failed ('%s' -> '%s')", src, dst) + + // only copy if files have different name/size + if (srcfi.Name == dstfi.Name && srcfi.size == dstfi.Size) { + cSrc := C.CString(src) + cDst := C.CString(dst) + if uint32(C.copyf(cSrc, cDst)) != 0 { + err = fmt.Errorf("copyf failed ('%s' -> '%s')", src, dst) + } + C.free(unsafe.Pointer(cSrc)) + C.free(unsafe.Pointer(cDst)) } - C.free(unsafe.Pointer(cSrc)) - C.free(unsafe.Pointer(cDst)) return }