Skip to content

fix: Resolve symlinks being written with size 0 in tar #1488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2022
Merged

Conversation

kylecarbs
Copy link
Member

Solution found here:
https://stackoverflow.com/questions/38454850/getting-write-too-long-error-when-trying-to-create-tar-gz-file-from-file-and-d

Symlink's were being written with a size of 0, which surfaced an error
for write too long.

@kylecarbs kylecarbs requested a review from coadler May 16, 2022 19:48
@kylecarbs kylecarbs self-assigned this May 16, 2022
Comment on lines +28 to +35
var link string
if fileInfo.Mode()&os.ModeSymlink == os.ModeSymlink {
link, err = os.Readlink(file)
if err != nil {
return err
}
}
header, err := tar.FileInfoHeader(fileInfo, link)
Copy link
Contributor

@coadler coadler May 16, 2022

Choose a reason for hiding this comment

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

This is a bit confusing. It seems like this only works for symlinks, since we're no longer using the file var if it's not.

Copy link
Member Author

Choose a reason for hiding this comment

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

The second arg is actually only a link. It was implemented incorrectly beforehand.

Copy link
Contributor

Choose a reason for hiding this comment

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

So it should be empty if the file isn't a symlink?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe so

@kylecarbs kylecarbs enabled auto-merge (squash) May 16, 2022 20:21
@kylecarbs kylecarbs merged commit a77da84 into main May 16, 2022
@kylecarbs kylecarbs deleted the symload branch May 16, 2022 20:26
kylecarbs added a commit that referenced this pull request Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants