1
0
mirror of https://github.com/p2r3/bareiron.git synced 2025-10-01 23:25:09 +02:00

add option to sync block changes on an interval

This commit is contained in:
p2r3
2025-09-02 00:29:21 +03:00
parent 7a81625cd4
commit 64846381f4
3 changed files with 26 additions and 4 deletions

View File

@@ -115,6 +115,12 @@ int initSerializer () {
// Writes a range of block change entries to disk
void writeBlockChangesToDisk (int from, int to) {
#ifdef DISK_SYNC_BLOCKS_ON_INTERVAL
// Skip this write if enough time hasn't passed since the last one
if (get_program_time() - last_disk_sync_time < DISK_SYNC_INTERVAL) return;
last_disk_sync_time = get_program_time();
#endif
// Try to open the file in rw (without overwriting)
FILE *file = fopen(FILE_PATH, "r+b");
if (!file) {