Skip to content

Commit cc6dc8d

Browse files
committed
use opportunistic reflink for copying files
1 parent 125072e commit cc6dc8d

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ require (
9595
github.com/mattn/go-shellwords v1.0.12
9696
github.com/spf13/afero v1.15.0
9797
github.com/testcontainers/testcontainers-go v0.41.0
98+
github.com/thisguycodes/copy v0.0.0-20260330081957-1daf4a9cab34
9899
github.com/wI2L/jsondiff v0.7.0
99100
github.com/xeipuuv/gojsonschema v1.2.0
100101
go.uber.org/mock v0.6.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,8 @@ github.com/tencentcloud/tencentcloud-sdk-go v0.0.0-20190816164403-f8fa457a3c72/g
954954
github.com/tencentyun/cos-go-sdk-v5 v0.0.0-20190808065407-f07404cefc8c/go.mod h1:wk2XFUg6egk4tSDNZtXeKfe2G6690UVyt163PuUxBZk=
955955
github.com/testcontainers/testcontainers-go v0.41.0 h1:mfpsD0D36YgkxGj2LrIyxuwQ9i2wCKAD+ESsYM1wais=
956956
github.com/testcontainers/testcontainers-go v0.41.0/go.mod h1:pdFrEIfaPl24zmBjerWTTYaY0M6UHsqA1YSvsoU40MI=
957+
github.com/thisguycodes/copy v0.0.0-20260330081957-1daf4a9cab34 h1:W5GGkFs0Dcv1COvDOi+9MGzcqlQwkVKVS/+tArz8TDo=
958+
github.com/thisguycodes/copy v0.0.0-20260330081957-1daf4a9cab34/go.mod h1:+SwikrVoNbN+m/M0bR7NrfWUF/bMSQAZlcZMaMOUCmc=
957959
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
958960
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
959961
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=

internal/util/file.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/gruntwork-io/terragrunt/pkg/log"
2222
"github.com/mattn/go-zglob"
2323
"github.com/mitchellh/go-homedir"
24+
"github.com/thisguycodes/copy"
2425
)
2526

2627
const (
@@ -504,13 +505,7 @@ func TerragruntExcludes(path string) bool {
504505

505506
// CopyFile copies a file from source to destination.
506507
func CopyFile(source string, destination string) error {
507-
file, err := os.Open(source)
508-
if err != nil {
509-
return errors.New(err)
510-
}
511-
defer file.Close()
512-
513-
return WriteFileWithSamePermissions(source, destination, file)
508+
return copy.Copy(source, destination)
514509
}
515510

516511
// WriteFileWithSamePermissions writes a file to the given destination with the given contents

0 commit comments

Comments
 (0)