Investigate and fix unwanted storage of junk/invalid data in `DataStoreLevel` implementation
thehenrytsai opened this issue · comments
Henry Tsai commented
There appears a bug in DataStoreLevel.put()
implementation where if there exists a piece of data with dataCid
X in the store, and another put()
is called with the same tenantId
and dataCid
X but incorrect data stream, this incorrect data would be stored indefinitely as chunks.
A potential way to fix this is to:
- push the
dataCid
check currently done by the caller ofput()
intoput()
itself. - attempt to see if an existing data with
dataCid
X is in the store, if in this store, then read the data stream into a temporary location (to be deleted later). If not in the store, then proceed to happy/common path (also require code tweaks in this path. - validate the dataCid of data in temporary location and react accordingly.