Open xuset opened 7 years ago
The piece hashes for the old and new torrent should be diff-ed and then copied over to the new store.
We should copy pieces instead of packages
Post-Mortem:
I added the code to copy identical files or zeroes from old snapshots into the IndexedDB store used by WebTorrent. However, the stream that we use to read files from the store depends on uninitiated pieces having no value in the store, thus requiring us to rethink how to handled uninitialized pieces. Additionally, files in the store are not piece aligned, which would likely require us to adapt the createTorrent
package.
These issues raised the complexity and difficulty of this task past the opportunity cost of pursuing this issue now. We will have to revisit this task later when it becomes a blocker for adoption.
When an update is found a new snapshot is created, the snapshot is downloaded from scratch despite the high likely that older snapshots already contain some of the needed data. This should be fixed by iterating over old snapshots and seeing if the old and new snapshot have any pieces in common by comparing the piece's hash. If the pieces are identical then copy the piece from the old snapshot's chunk store to the new.