DatabaseBackup

Pure rules for backing up and restoring the app database: file naming, header validation and staging paths.

Types

Link copied to clipboard
sealed interface Validation

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val HEADER_SIZE: Int = 100

Bytes of the SQLite file header needed to read the magic string and user_version.

Link copied to clipboard
const val MIME_TYPE: String
Link copied to clipboard
const val SCHEMA_VERSION: Int = 69

Must equal @Database(version) on MeshtasticDatabase; a jvmTest opens a real database and checks it.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun fileName(deviceId: String?, now: Instant, timeZone: TimeZone = TimeZone.currentSystemDefault()): String

Name for a backup of the database belonging to deviceId, dated from now. A device id that is not the hex form current ingestion produces is replaced by a fixed word so the name never carries arbitrary characters.

Link copied to clipboard
fun stagedPath(dbFile: Path): Path

Where a validated restore for the database at dbFile waits until that database is next opened.

Link copied to clipboard
fun validateHeader(header: ByteArray, expectedVersion: Int = SCHEMA_VERSION): DatabaseBackup.Validation

Checks the SQLite magic string and that user_version (where Room stores the schema version) matches.