Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit a3d67e9

Browse files
authored
don't snapshot empty db files (#730)
1 parent 1f3d773 commit a3d67e9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

bottomless/src/replicator.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1095,13 +1095,17 @@ impl Replicator {
10951095
if let Ok(page_size) = Self::read_page_size(&mut db).await {
10961096
self.set_page_size(page_size)?;
10971097
}
1098-
// if database file exists always treat it as new and more up to date, skipping the
1099-
// restoration process and calling for a new generation to be made
1100-
return Ok(Some(RestoreAction::SnapshotMainDbFile));
1098+
Self::read_change_counter(&mut db).await.unwrap_or([0u8; 4])
11011099
}
11021100
Err(_) => [0u8; 4],
11031101
};
11041102

1103+
if local_counter != [0u8; 4] {
1104+
// if a non-empty database file exists always treat it as new and more up to date,
1105+
// skipping the restoration process and calling for a new generation to be made
1106+
return Ok(Some(RestoreAction::SnapshotMainDbFile));
1107+
}
1108+
11051109
let remote_counter = self.get_remote_change_counter(&generation).await?;
11061110
tracing::debug!("Counters: l={:?}, r={:?}", local_counter, remote_counter);
11071111

0 commit comments

Comments
 (0)