Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Extract hard links from tar #199

Merged

Conversation

priyawadhwa
Copy link
Contributor

No description provided.

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)
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
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)
Copy link
Contributor

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?

Copy link
Contributor Author

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

// If it exists, create the hard link
resolveHardlink(linkname, target)
} else {
logrus.Errorf("Unable to create hard link from %s to %s", linkname, target)
Copy link
Contributor

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

}
}
return nil
}

func resolveHardlink(linkname, target string) {
Copy link
Contributor

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)

@priyawadhwa priyawadhwa merged commit bc5c88f into GoogleContainerTools:master Mar 9, 2018
@priyawadhwa priyawadhwa deleted the extract-hardlinks branch March 9, 2018 19:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants