@@ -127,10 +127,7 @@ func unpackTar(tr *tar.Reader, path string, whitelist []string) error {
127
127
// Check if the linkname already exists
128
128
if _ , err := os .Stat (linkname ); ! os .IsNotExist (err ) {
129
129
// If it exists, create the hard link
130
- if err := os .Link (linkname , target ); err != nil {
131
- logrus .Warnf ("Failed to create hard link between %s and %s: %v" , linkname , target , err )
132
- }
133
- logrus .Debugf ("Created hard link from %s to %s" , linkname , target )
130
+ resolveHardlink (linkname , target )
134
131
} else {
135
132
hardlinks [target ] = linkname
136
133
}
@@ -141,17 +138,22 @@ func unpackTar(tr *tar.Reader, path string, whitelist []string) error {
141
138
logrus .Info ("Resolving hard links." )
142
139
if _ , err := os .Stat (linkname ); ! os .IsNotExist (err ) {
143
140
// If it exists, create the hard link
144
- if err := os .Link (linkname , target ); err != nil {
145
- logrus .Warnf ("Unable to create hard link from %s to %s: %v" , linkname , target , err )
146
- }
147
- logrus .Debugf ("Created hard link from %s to %s" , linkname , target )
141
+ resolveHardlink (linkname , target )
148
142
} else {
149
- logrus .Warnf ("Unable to create hard link from %s to %s" , linkname , target )
143
+ logrus .Errorf ("Unable to create hard link from %s to %s" , linkname , target )
150
144
}
151
145
}
152
146
return nil
153
147
}
154
148
149
+ func resolveHardlink (linkname , target string ) {
150
+ if err := os .Link (linkname , target ); err != nil {
151
+ logrus .Warnf ("Unable to create hard link from %s to %s: %v" , linkname , target , err )
152
+ } else {
153
+ logrus .Debugf ("Created hard link from %s to %s" , linkname , target )
154
+ }
155
+ }
156
+
155
157
func checkWhitelist (target string , whitelist []string ) bool {
156
158
for _ , w := range whitelist {
157
159
if HasFilepathPrefix (target , w ) {
0 commit comments