@@ -56,11 +56,12 @@ impl MetadataFile {
5656 path. write ( self . to_string ( ) )
5757 }
5858
59- fn check_compatibility ( previous : & Self , current : & Self ) -> anyhow:: Result < ( ) > {
59+ fn check_compatibility ( previous : & Self , current : & Self , metafile : & Path ) -> anyhow:: Result < ( ) > {
6060 anyhow:: ensure!(
6161 previous. edition == current. edition,
62- "metadata.toml indicates that this database is from a different \
62+ "metadata.toml at {} indicates that this database is from a different \
6363 edition of SpacetimeDB (running {:?}, but this database is {:?})",
64+ metafile. display( ) ,
6465 current. edition,
6566 previous. edition,
6667 ) ;
@@ -110,8 +111,8 @@ impl MetadataFile {
110111 /// `self` is the metadata file read from a database, and current is
111112 /// the default metadata file that the active database version would
112113 /// right to a new database.
113- pub fn check_compatibility_and_update ( mut self , current : Self ) -> anyhow:: Result < Self > {
114- Self :: check_compatibility ( & self , & current) ?;
114+ pub fn check_compatibility_and_update ( mut self , current : Self , metafile : & Path ) -> anyhow:: Result < Self > {
115+ Self :: check_compatibility ( & self , & current, metafile ) ?;
115116 // bump the version in the file only if it's being run in a newer database.
116117 self . version = std:: cmp:: max ( self . version , current. version ) ;
117118 Ok ( self )
@@ -344,67 +345,67 @@ mod tests {
344345 fn check_metadata_compatibility_checking ( ) {
345346 assert_eq ! (
346347 mkmeta( 1 , 0 , 0 )
347- . check_compatibility_and_update( mkmeta( 1 , 0 , 1 ) )
348+ . check_compatibility_and_update( mkmeta( 1 , 0 , 1 ) , Path :: new ( "metadata.toml" ) )
348349 . unwrap( )
349350 . version,
350351 mkver( 1 , 0 , 1 )
351352 ) ;
352353 assert_eq ! (
353354 mkmeta( 1 , 0 , 1 )
354- . check_compatibility_and_update( mkmeta( 1 , 0 , 0 ) )
355+ . check_compatibility_and_update( mkmeta( 1 , 0 , 0 ) , Path :: new ( "metadata.toml" ) )
355356 . unwrap( )
356357 . version,
357358 mkver( 1 , 0 , 1 )
358359 ) ;
359360
360361 mkmeta ( 1 , 1 , 0 )
361- . check_compatibility_and_update ( mkmeta ( 1 , 0 , 5 ) )
362+ . check_compatibility_and_update ( mkmeta ( 1 , 0 , 5 ) , Path :: new ( "metadata.toml" ) )
362363 . unwrap_err ( ) ;
363364 mkmeta ( 2 , 0 , 0 )
364- . check_compatibility_and_update ( mkmeta ( 1 , 3 , 5 ) )
365+ . check_compatibility_and_update ( mkmeta ( 1 , 3 , 5 ) , Path :: new ( "metadata.toml" ) )
365366 . unwrap_err ( ) ;
366367 assert_eq ! (
367368 mkmeta( 1 , 12 , 0 )
368- . check_compatibility_and_update( mkmeta( 2 , 0 , 0 ) )
369+ . check_compatibility_and_update( mkmeta( 2 , 0 , 0 ) , Path :: new ( "metadata.toml" ) )
369370 . unwrap( )
370371 . version,
371372 mkver( 2 , 0 , 0 )
372373 ) ;
373374 mkmeta ( 2 , 0 , 0 )
374- . check_compatibility_and_update ( mkmeta ( 3 , 0 , 0 ) )
375+ . check_compatibility_and_update ( mkmeta ( 3 , 0 , 0 ) , Path :: new ( "metadata.toml" ) )
375376 . unwrap_err ( ) ;
376377 }
377378
378379 #[ test]
379380 fn check_metadata_compatibility_prerelease ( ) {
380381 mkmeta ( 1 , 9 , 0 )
381- . check_compatibility_and_update ( mkmeta_pre ( 2 , 0 , 0 , "rc1" ) )
382+ . check_compatibility_and_update ( mkmeta_pre ( 2 , 0 , 0 , "rc1" ) , Path :: new ( "metadata.toml" ) )
382383 . unwrap ( ) ;
383384
384385 mkmeta_pre ( 2 , 0 , 0 , "rc1" )
385- . check_compatibility_and_update ( mkmeta_pre ( 2 , 0 , 0 , "rc1" ) )
386+ . check_compatibility_and_update ( mkmeta_pre ( 2 , 0 , 0 , "rc1" ) , Path :: new ( "metadata.toml" ) )
386387 . unwrap ( ) ;
387388
388389 mkmeta_pre ( 2 , 0 , 0 , "rc1" )
389- . check_compatibility_and_update ( mkmeta ( 2 , 0 , 1 ) )
390+ . check_compatibility_and_update ( mkmeta ( 2 , 0 , 1 ) , Path :: new ( "metadata.toml" ) )
390391 . unwrap ( ) ;
391392
392393 mkmeta_pre ( 2 , 0 , 0 , "rc1" )
393- . check_compatibility_and_update ( mkmeta ( 2 , 0 , 0 ) )
394+ . check_compatibility_and_update ( mkmeta ( 2 , 0 , 0 ) , Path :: new ( "metadata.toml" ) )
394395 . unwrap ( ) ;
395396
396397 // Now check some failures..
397398
398399 mkmeta_pre ( 2 , 0 , 0 , "rc1" )
399- . check_compatibility_and_update ( mkmeta_pre ( 2 , 0 , 0 , "rc2" ) )
400+ . check_compatibility_and_update ( mkmeta_pre ( 2 , 0 , 0 , "rc2" ) , Path :: new ( "metadata.toml" ) )
400401 . unwrap_err ( ) ;
401402
402403 mkmeta_pre ( 2 , 0 , 0 , "rc2" )
403- . check_compatibility_and_update ( mkmeta_pre ( 2 , 0 , 0 , "rc1" ) )
404+ . check_compatibility_and_update ( mkmeta_pre ( 2 , 0 , 0 , "rc1" ) , Path :: new ( "metadata.toml" ) )
404405 . unwrap_err ( ) ;
405406
406407 mkmeta ( 2 , 0 , 0 )
407- . check_compatibility_and_update ( mkmeta_pre ( 2 , 1 , 0 , "rc1" ) )
408+ . check_compatibility_and_update ( mkmeta_pre ( 2 , 1 , 0 , "rc1" ) , Path :: new ( "metadata.toml" ) )
408409 . unwrap_err ( ) ;
409410 }
410411
0 commit comments