Skip to main content

maybe_init_database_file

Function maybe_init_database_file 

Source
pub fn maybe_init_database_file(
    file: &Arc<dyn File>,
    io: &Arc<dyn IO>,
) -> Result<bool>
Expand description

Initialize a brand-new database file (write the bootstrap page 1) if the file is empty.

Returns true when the file was freshly created (its size was 0 before this call wrote the bootstrap header), and false when an existing, non-empty database file was opened. Callers use this to detect the “fresh main DB file + pre-existing -wal” situation, where the WAL is orphaned from a previous database incarnation and MUST NOT be replayed (see storage::wal::WalFileShared::open_shared).