hypercore-storage 1.2.0 → 1.2.1

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.
@@ -605,24 +605,35 @@ function readOplog (oplog) {
605
605
  result.header = header ? h2.message : h1.message
606
606
 
607
607
  if (result.header.external) {
608
- throw new Error('External headers not migrate-able atm')
608
+ fs.readFile(path.join(oplog, '../header'), function (err, buffer) {
609
+ if (err) return resolve(null)
610
+ const start = result.header.external.start
611
+ const end = start + result.header.external.length
612
+ result.header = m.oplog.header.decode({ buffer, start, end })
613
+ finish()
614
+ })
615
+ return
609
616
  }
610
617
 
611
- while (true) {
612
- const entry = decodeOplogEntry(state)
613
- if (!entry) break
614
- if (entry.header !== header) break
618
+ finish()
615
619
 
616
- decoded.push(entry)
617
- }
620
+ function finish () {
621
+ while (true) {
622
+ const entry = decodeOplogEntry(state)
623
+ if (!entry) break
624
+ if (entry.header !== header) break
618
625
 
619
- while (decoded.length > 0 && decoded[decoded.length - 1].partial) decoded.pop()
626
+ decoded.push(entry)
627
+ }
620
628
 
621
- for (const e of decoded) {
622
- result.entries.push(e.message)
623
- }
629
+ while (decoded.length > 0 && decoded[decoded.length - 1].partial) decoded.pop()
624
630
 
625
- resolve(result)
631
+ for (const e of decoded) {
632
+ result.entries.push(e.message)
633
+ }
634
+
635
+ resolve(result)
636
+ }
626
637
  })
627
638
  })
628
639
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-storage",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",