Skip to content

Commit 630c55f

Browse files
committed
libsql: Fix SyncContext::new() metadata reading
If we fail to read the metadata file, we must return an error. Resetting the metadata leads to inconsistent state because you have no way to tell what the database represents.
1 parent 5672a1a commit 630c55f

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

libsql/src/sync.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,10 @@ impl SyncContext {
171171
initial_server_sync: false,
172172
remote_encryption,
173173
};
174-
175-
if let Err(e) = me.read_metadata().await {
176-
tracing::error!(
177-
"failed to read sync metadata file, resetting back to defaults: {}",
178-
e
179-
);
174+
me.read_metadata().await?;
175+
if me.durable_generation == 0 {
176+
return Err(SyncError::InvalidLocalState("generation is 0".to_string()).into());
180177
}
181-
182178
Ok(me)
183179
}
184180

0 commit comments

Comments
 (0)