-
Notifications
You must be signed in to change notification settings - Fork 237
Extract hard links from tar #199
Extract hard links from tar #199
Conversation
pkg/util/tar_utils.go
Outdated
if _, err := os.Stat(linkname); !os.IsNotExist(err) { | ||
// If it exists, create the hard link | ||
if err := os.Link(linkname, target); err != nil { | ||
logrus.Warnf("Failed to create hard link between %s and %s: %v", linkname, target, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is slightly different from the one below. Maybe factor this logic out into a small helper method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/util/tar_utils.go
Outdated
} | ||
logrus.Debugf("Created hard link from %s to %s", linkname, target) | ||
} else { | ||
logrus.Warnf("Unable to create hard link from %s to %s", linkname, target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what case would this fail? Should we be erroring here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of any case in which it should fail at this point, so an error would probably make more sense here
pkg/util/tar_utils.go
Outdated
// If it exists, create the hard link | ||
resolveHardlink(linkname, target) | ||
} else { | ||
logrus.Errorf("Unable to create hard link from %s to %s", linkname, target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, can you return this error? we should be sending these back to the top level and handling them there
pkg/util/tar_utils.go
Outdated
} | ||
} | ||
return nil | ||
} | ||
|
||
func resolveHardlink(linkname, target string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you return an error from this function? then you can just have the error message here and get rid of the one above. you can use errors.Wrap(err, errMsg)
No description provided.