@@ -109,18 +109,24 @@ where
109
109
/// # let new_len = file.seek(SeekFrom::End(-2))?;
110
110
/// # file.set_len(new_len)?;
111
111
///
112
- /// let mut new_store = match Store::<TestChangeSet>::load(&MAGIC_BYTES, &file_path) {
112
+ /// let (mut new_store, _aggregate_changeset) =
113
+ /// match Store::<TestChangeSet>::load(&MAGIC_BYTES, &file_path) {
113
114
/// # Ok(_) => panic!("should have errored"),
114
- /// Ok((store, _aggregated_changeset)) => store,
115
- /// Err(StoreErrorWithDump { changeset, .. }) => {
116
- /// let new_file_path = file_path.with_extension("bkp");
117
- /// let mut new_store = Store::create(&MAGIC_BYTES, &new_file_path).unwrap();
118
- /// if let Some(aggregated_changeset) = changeset {
119
- /// new_store.append(&aggregated_changeset)?;
115
+ /// Ok((store, changeset)) => (store, changeset),
116
+ /// Err(StoreErrorWithDump { changeset, .. }) => {
117
+ /// let new_file_path = file_path.with_extension("backup");
118
+ /// let mut new_store =
119
+ /// Store::create(&MAGIC_BYTES, &new_file_path).expect("must create new file");
120
+ /// if let Some(aggregated_changeset) = changeset {
121
+ /// new_store.append(&aggregated_changeset)?;
122
+ /// }
123
+ /// // The following will overwrite the original file. You will loose the corrupted
124
+ /// // portion of the original file forever.
125
+ /// drop(new_store);
126
+ /// std::fs::rename(&new_file_path, &file_path)?;
127
+ /// Store::load(&MAGIC_BYTES, &file_path).expect("must load new file")
120
128
/// }
121
- /// new_store
122
- /// }
123
- /// };
129
+ /// };
124
130
/// #
125
131
/// # assert_eq!(
126
132
/// # new_store.dump().expect("should dump changeset: {1, 2, 3} "),
0 commit comments