ReplaceFileCorruptionHandler

A corruption handler that attempts to replace the on-disk data with data from produceNewData.

If the handler successfully replaces the data, the original exception is swallowed. If the handler encounters an exception when attempting to replace data, the new exception is added as a suppressed exception to the original exception and the original exception is thrown.

A corruption handler that attempts to replace the on-disk data with data from produceNewData.

If the handler successfully replaces the data, the original exception is swallowed. If the handler encounters an exception when attempting to replace data, the new exception is added as a suppressed exception to the original exception and the original exception is thrown.

A corruption handler that attempts to replace the on-disk data with data from produceNewData.

If the handler successfully replaces the data, the original exception is swallowed. If the handler encounters an exception when attempting to replace data, the new exception is added as a suppressed exception to the original exception and the original exception is thrown.

Parameters

produceNewData

The provided callback returns the data to be written to disk. If the callback fails, nothing will be written to disk. Since the exception will be swallowed after writing the data, this is a good place to log the exception.

produceNewData

The provided callback returns the data to be written to disk. If the callback fails, nothing will be written to disk. Since the exception will be swallowed after writing the data, this is a good place to log the exception.

Constructors

Link copied to clipboard

Functions

Link copied to clipboard
abstract suspend fun handleCorruption(ex: CorruptionException): T

This function will be called by DataStore when it encounters corruption. If the implementation of this function throws an exception, it will be propagated to the original call to DataStore. Otherwise, the returned data will be written to disk.

open suspend override fun handleCorruption(ex: CorruptionException): T

This function will be called by DataStore when it encounters corruption. If the implementation of this function throws an exception, it will be propagated to the original call to DataStore. Otherwise, the returned data will be written to disk.

open suspend override fun handleCorruption(ex: CorruptionException): T

This function will be called by DataStore when it encounters corruption. If the implementation of this function throws an exception, it will be propagated to the original call to DataStore. Otherwise, the returned data will be written to disk.