Skip to content
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

Use tar checksum instead of md5 of the files and fix memory bloat #92

Closed
wants to merge 3 commits into from

Conversation

ChrisCinelli
Copy link
Contributor

Fixes #27 and point 1 in #90

@wagoodman
Copy link
Owner

Thanks for the PR, however, based on the feed back from #90 (comment) I'm going to close this PR.

Also, I was looking for a way to get this functionality without forking the tar lib and it came down to this approach:

	hdrBuf := new(bytes.Buffer)

	tarFile, err := os.Open("image.tar")
	if err != nil {
		fmt.Printf("ERROR: %v\n", err)
	}

	tr := tar.NewReader(io.TeeReader(tarFile, hdrBuf))

	for {
		hdrBuf.Reset()
		header, err := tr.Next()
		if err == io.EOF {
			break
		} 
		hdrBuf.Next(hdrBuf.Len() % 512)

		fmt.Printf("%s\n", hex.Dump(hdrBuf.Bytes()))
		fmt.Printf("Type: %v\n", header.Format)
		fmt.Printf("Chksum: %v\n", string(hdrBuf.Bytes()[148:][:8]))
	}

This way we could grab only the bytes we need and avoid drifting implementation from forking tar.

@wagoodman wagoodman closed this Nov 28, 2018
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