From 84f5e0b4df52132f0c860b87e66ad3d1922100c4 Mon Sep 17 00:00:00 2001 From: Jameson Little Date: Sun, 31 Jul 2011 20:08:42 -0600 Subject: [PATCH 1/2] Fixed bug when appending a file whose size is a multiple of 512 bytes --- lib/tar.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tar.js b/lib/tar.js index 161706e..e670b21 100644 --- a/lib/tar.js +++ b/lib/tar.js @@ -56,8 +56,8 @@ checksum: ' ', type: '0', // just a file ustar: 'ustar ', - owner: '', - group: '' + owner: opts.owner || '', + group: opts.group || '' }; // calculate the checksum @@ -88,7 +88,7 @@ this.out.set(input, this.written); // to the nearest multiple of recordSize - this.written += input.length + (recordSize - (input.length % recordSize)); + this.written += input.length + (recordSize - (input.length % recordSize || recordSize)); // make sure there's at least 2 empty records worth of extra space if (this.out.length - this.written < recordSize * 2) { diff --git a/package.json b/package.json index 36d5f1b..42181d7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tar-js", "description": "Tar implemented in the browser", - "version": "0.1.0", + "version": "0.1.1", "homepage": "http://github.com/beatgammit/tar-js", "repository": { "type": "git", From 4763e4c2c39b28f2f8a14d2c36d2dbb8e094a46b Mon Sep 17 00:00:00 2001 From: Jameson Little Date: Sun, 31 Jul 2011 20:09:56 -0600 Subject: [PATCH 2/2] Example now uses built-in btoa instead of custom base64 encoding --- examples/index.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/index.html b/examples/index.html index 2c024f5..7265319 100644 --- a/examples/index.html +++ b/examples/index.html @@ -19,11 +19,20 @@ url, base64; + function uint8ToString(buf) { + var i, length, out = ''; + for (i = 0, length = buf.length; i < length; i += 1) { + out += String.fromCharCode(buf[i]); + } + + return out; + } + out = tape.append('output.txt', 'This is test1!'); out = tape.append('dir/out.txt', 'This is test2! I changed up the directory'); out = tape.append('arr.txt', utils.stringToUint8('This is a Uint8Array!')); - base64 = utils.uint8ToBase64(out); + base64 = btoa(uint8ToString(out)); url = "data:application/tar;base64," + base64; window.open(url);