cbyte 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cbyte.js +6 -7
- package/package.json +1 -1
package/cbyte.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// Increase listener limit to avoid warnings
|
|
4
|
-
// require('events').defaultMaxListeners = 6000;
|
|
5
4
|
import evt from 'events';
|
|
6
5
|
import fs from 'fs';
|
|
7
6
|
import crypto from 'crypto';
|
|
@@ -56,7 +55,7 @@ async function pack(filePath, outFile, chunkSize = 4096, pin = false) {
|
|
|
56
55
|
|
|
57
56
|
const manifest = {
|
|
58
57
|
format: 'cbyte',
|
|
59
|
-
version: 1.
|
|
58
|
+
version: 1.10,
|
|
60
59
|
chunk_size: chunkSize,
|
|
61
60
|
original_size: data.length,
|
|
62
61
|
original_ext: path.extname(filePath),
|
|
@@ -88,7 +87,7 @@ async function pack(filePath, outFile, chunkSize = 4096, pin = false) {
|
|
|
88
87
|
});
|
|
89
88
|
|
|
90
89
|
uploaded++;
|
|
91
|
-
renderProgress(uploaded, hashes.length, 'Packing');
|
|
90
|
+
renderProgress(uploaded, hashes.length, 'Packing ...');
|
|
92
91
|
}));
|
|
93
92
|
}
|
|
94
93
|
process.stderr.write('\n');
|
|
@@ -104,7 +103,7 @@ async function unpack(manifestPath, outFile) {
|
|
|
104
103
|
const manifest = JSON.parse(fs.readFileSync(manifestPath));
|
|
105
104
|
if (!outFile) {
|
|
106
105
|
const base = path.basename(manifestPath, path.extname(manifestPath));
|
|
107
|
-
const ext = manifest.original_ext || '.
|
|
106
|
+
const ext = manifest.original_ext || '.bin';
|
|
108
107
|
outFile = `${base}${ext}`;
|
|
109
108
|
}
|
|
110
109
|
|
|
@@ -120,7 +119,7 @@ async function unpack(manifestPath, outFile) {
|
|
|
120
119
|
for (let j = 0; j < entry.count; j++) {
|
|
121
120
|
fs.writeSync(fd, blockBytes.slice(0, entry.length));
|
|
122
121
|
completed++;
|
|
123
|
-
renderProgress(completed, total, 'Unpacking');
|
|
122
|
+
renderProgress(completed, total, 'Unpacking... ');
|
|
124
123
|
}
|
|
125
124
|
}));
|
|
126
125
|
}
|
|
@@ -158,14 +157,14 @@ async function pin(manifestPath) {
|
|
|
158
157
|
for (const { cid } of manifest.chunks) {
|
|
159
158
|
await helia.pin.add(cid);
|
|
160
159
|
pinned++;
|
|
161
|
-
renderProgress(pinned, manifest.chunks.length, 'Pinning');
|
|
160
|
+
renderProgress(pinned, manifest.chunks.length, 'Pinning...');
|
|
162
161
|
}
|
|
163
162
|
process.stderr.write('\n');
|
|
164
163
|
console.log('All blocks pinned');
|
|
165
164
|
}
|
|
166
165
|
|
|
167
166
|
// CLI definition
|
|
168
|
-
program.version('1.
|
|
167
|
+
program.version('1.10.0');
|
|
169
168
|
|
|
170
169
|
program
|
|
171
170
|
.command('pack <file>')
|