@@ -182,46 +182,16 @@ pub trait MigratableKVStore: KVStore {
182
182
/// might get overriden. User must ensure `source_store` is not modified during operation,
183
183
/// otherwise no consistency guarantees can be given.
184
184
///
185
- /// Will re-read and validate the written data if `validate_data` is set.
186
- ///
187
185
/// Will abort and return an error if any IO operation fails. Note that in this case the
188
186
/// `target_store` might get left in an intermediate state.
189
- ///
190
- /// **Caution**: Will delete all data from `source_store` if `move_data` is set.
191
187
pub fn migrate_kv_store_data < S : MigratableKVStore , T : MigratableKVStore > (
192
- source_store : & mut S , target_store : & mut T , validate_data : bool , move_data : bool ,
188
+ source_store : & mut S , target_store : & mut T ,
193
189
) -> Result < ( ) , io:: Error > {
194
190
let keys_to_migrate = source_store. list_all_keys ( ) ?;
195
191
196
- // First copy over all data.
197
192
for ( primary_namespace, secondary_namespace, key) in & keys_to_migrate {
198
193
let data = source_store. read ( primary_namespace, secondary_namespace, key) ?;
199
194
target_store. write ( primary_namespace, secondary_namespace, key, & data) ?;
200
-
201
- // Now validate what we've written.
202
- if validate_data {
203
- let read_data = target_store. read ( primary_namespace, secondary_namespace, & key) ?;
204
- if data != read_data {
205
- let err =
206
- io:: Error :: new ( io:: ErrorKind :: InvalidData , "Failed to validate migrated data" ) ;
207
- return Err ( err) ;
208
- }
209
- }
210
- }
211
-
212
- // If we succeeded and `move_data` is set, remove all migrated keys.
213
- if move_data {
214
- for ( primary_namespace, secondary_namespace, key) in & keys_to_migrate {
215
- source_store. remove ( primary_namespace, secondary_namespace, & key, false ) ?;
216
- }
217
-
218
- if !source_store. list_all_keys ( ) ?. is_empty ( ) {
219
- let err = io:: Error :: new (
220
- io:: ErrorKind :: InvalidData ,
221
- "Source store is not empty. Was it modified during migration? This should never happen!"
222
- ) ;
223
- return Err ( err) ;
224
- }
225
195
}
226
196
227
197
Ok ( ( ) )
0 commit comments