Skip to content

Commit d8ae4e6

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

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ require (
272272
github.com/shopspring/decimal v1.4.0 // indirect
273273
github.com/spf13/cast v1.10.0 // indirect
274274
github.com/spiffe/go-spiffe/v2 v2.6.0 // indirect
275+
github.com/thisguycodes/copy v0.0.0-20260330081957-1daf4a9cab34 // indirect
275276
github.com/tidwall/gjson v1.18.0 // indirect
276277
github.com/tidwall/match v1.1.1 // indirect
277278
github.com/tidwall/pretty v1.2.1 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,10 @@ 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-20260330075139-114256357a88 h1:KVLpSmGXmo///aoJIiQA0uLaSiPhpk0KBOkXuYk+ZEk=
958+
github.com/thisguycodes/copy v0.0.0-20260330075139-114256357a88/go.mod h1:+SwikrVoNbN+m/M0bR7NrfWUF/bMSQAZlcZMaMOUCmc=
959+
github.com/thisguycodes/copy v0.0.0-20260330081957-1daf4a9cab34 h1:W5GGkFs0Dcv1COvDOi+9MGzcqlQwkVKVS/+tArz8TDo=
960+
github.com/thisguycodes/copy v0.0.0-20260330081957-1daf4a9cab34/go.mod h1:+SwikrVoNbN+m/M0bR7NrfWUF/bMSQAZlcZMaMOUCmc=
957961
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
958962
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
959963
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)