@@ -1883,7 +1883,7 @@ func (s *SourceState) newFileTargetStateEntryFunc(
1883
1883
}, nil
1884
1884
}
1885
1885
}
1886
- executedContentsFunc := func () ([]byte , error ) {
1886
+ executedContentsFunc := sync . OnceValues ( func () ([]byte , error ) {
1887
1887
contents , err := contentsFunc ()
1888
1888
if err != nil {
1889
1889
return nil , err
@@ -1899,7 +1899,7 @@ func (s *SourceState) newFileTargetStateEntryFunc(
1899
1899
}
1900
1900
}
1901
1901
return contents , nil
1902
- }
1902
+ })
1903
1903
return & TargetStateFile {
1904
1904
contentsFunc : executedContentsFunc ,
1905
1905
contentsSHA256Func : lazySHA256 (executedContentsFunc ),
@@ -1922,7 +1922,7 @@ func (s *SourceState) newModifyTargetStateEntryFunc(
1922
1922
interpreter * Interpreter ,
1923
1923
) targetStateEntryFunc {
1924
1924
return func (destSystem System , destAbsPath AbsPath ) (TargetStateEntry , error ) {
1925
- contentsFunc := func () (contents []byte , err error ) {
1925
+ contentsFunc := sync . OnceValues ( func () (contents []byte , err error ) {
1926
1926
// FIXME this should share code with RealSystem.RunScript
1927
1927
1928
1928
// Read the current contents of the target.
@@ -2019,7 +2019,7 @@ func (s *SourceState) newModifyTargetStateEntryFunc(
2019
2019
cmd .Stderr = os .Stderr
2020
2020
contents , err = chezmoilog .LogCmdOutput (s .logger , cmd )
2021
2021
return
2022
- }
2022
+ })
2023
2023
return & TargetStateFile {
2024
2024
contentsFunc : contentsFunc ,
2025
2025
contentsSHA256Func : lazySHA256 (contentsFunc ),
@@ -2043,12 +2043,12 @@ func (s *SourceState) newScriptTargetStateEntryFunc(
2043
2043
sourceRelPath SourceRelPath ,
2044
2044
fileAttr FileAttr ,
2045
2045
targetRelPath RelPath ,
2046
- contentsFunc func () ([]byte , error ),
2046
+ sourceContentsFunc func () ([]byte , error ),
2047
2047
interpreter * Interpreter ,
2048
2048
) targetStateEntryFunc {
2049
2049
return func (destSystem System , destAbsPath AbsPath ) (TargetStateEntry , error ) {
2050
- contentsFunc := func () ([]byte , error ) {
2051
- contents , err := contentsFunc ()
2050
+ contentsFunc := sync . OnceValues ( func () ([]byte , error ) {
2051
+ contents , err := sourceContentsFunc ()
2052
2052
if err != nil {
2053
2053
return nil , err
2054
2054
}
@@ -2063,7 +2063,7 @@ func (s *SourceState) newScriptTargetStateEntryFunc(
2063
2063
}
2064
2064
}
2065
2065
return contents , nil
2066
- }
2066
+ })
2067
2067
return & TargetStateScript {
2068
2068
name : targetRelPath ,
2069
2069
contentsFunc : contentsFunc ,
0 commit comments