You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I tried to retrieve a binary blob (a 13k PNG file) using the #wip branch (on OSX):
Git.Repo.open(REPO_PATH, function(error, repo) {
repo.getBlob(oid, function(error, blob) {
var content = blob.content();
if (blob.isBinary()) {
fs.writeFileSync('BROKEN.png', content);
}
});
});
The first 4 or 5 bytes seem to match (they are ffd8 ffe0 00) but the rest of the bytes seem to be random memory; they change on subsequent retrievals of the same blob.
However, text files seem to work. Am I doing something dumb?
Activity
philschatz commentedon Sep 4, 2013
Also, a little self-contained repo that illustrates the problem: https://github.com/philschatz/nodegit-sample
nkallen commentedon Sep 5, 2013
Thanks for the self-contained repo, it saved me a ton of time fixing the problem. The latest
wipa9ee1dc should fix this problem:Old code
New code
I copied/pasted the solution from the commenter Jonathan Wiepert from http://www.samcday.com.au/blog/2011/03/03/creating-a-proper-buffer-in-a-node-c-addon/ -- hopefully this is a valid solution!
philschatz commentedon Sep 5, 2013
Thanks, it works great! For what it's worth, I'm using
nodegitto make a local test suite for https://github.com/philschatz/octokit.js (JS client for GitHub's API) which is used in a GitHub eBook editor: https://github.com/philschatz/github-bookFix issue nodegit/nodegit#83