Open timeswind opened 5 hours ago
This is expected behavior. Loro can only be used to import binary content that was exported from Loro, not to import arbitrary binary content.
If some bytes are corrupted, the best approach is to prevent users from importing rather than attempting to fix it. If you want to support error correction, you can wrap it in an additional layer externally, such as using error-correcting codes. If you forcefully import content based on corrupted data interpretation, it will put the document into a state of hidden corruption.
@zxch3n Is there way to detect if the byte are correct for loro data struct?
Yeah, every time import
is called, Loro will perform the integrity check. Alternatively, you can use decodeImportBlobMeta(blob: Uint8Array, check_integrity: boolean)
Currently when import any binary data, loro would throw error as
Uncaught Decode error: (Invalid magic bytes)
. How would loro planning to support data repair if some bytes were corrupted?