The old chunks are deleted FIRST and unconditionally. Overwriting a 3-chunk file with a 1-chunk
one by INSERT OR REPLACE alone would leave chunks 1 and 2 behind, and the next read -- which
trusts chunks from the metadata row -- would return the new first chunk followed by nothing,
silently truncating. Worse, a later overwrite back up to 3 chunks would splice the new chunk 0
onto the ORIGINAL chunks 1 and 2 and produce a file that never existed.
Stores a file, replacing any previous copy.
The old chunks are deleted FIRST and unconditionally. Overwriting a 3-chunk file with a 1-chunk one by INSERT OR REPLACE alone would leave chunks 1 and 2 behind, and the next read -- which trusts
chunksfrom the metadata row -- would return the new first chunk followed by nothing, silently truncating. Worse, a later overwrite back up to 3 chunks would splice the new chunk 0 onto the ORIGINAL chunks 1 and 2 and produce a file that never existed.