@@ -11,6 +11,7 @@ use std::fmt::Write;
1111use std:: path:: Path ;
1212use std:: { fs, panic} ;
1313use tokio:: signal:: ctrl_c;
14+ use uuid:: Uuid ;
1415
1516fn main ( ) -> Result < ( ) , i32 > {
1617 inner_main ( ) . map_err ( |err| {
@@ -62,7 +63,11 @@ fn inner_main() -> Result<()> {
6263 }
6364
6465 if user_config. init || user_config. import_from_v7 . is_some ( ) {
65- init_db ( & user_config. db_file , user_config. import_from_v7 . as_deref ( ) ) ?;
66+ init_db (
67+ & user_config. db_file ,
68+ user_config. import_from_v7 . as_deref ( ) ,
69+ user_config. fs_uuid ,
70+ ) ?;
6671 return Ok ( ( ) ) ;
6772 }
6873
@@ -149,10 +154,11 @@ doc.beegfs.io.",
149154 } )
150155}
151156
152- /// Create and initialize a new database. Optionally import v7 data from the given path.
157+ /// Create and initialize a new database.
153158///
154- /// The database file is only written to disk if the initialization succeeds.
155- fn init_db ( db_file : & Path , v7_path : Option < & Path > ) -> Result < ( ) > {
159+ /// Optionally import v7 data from the given path. Optionally the FsUUID can be specified otherwise
160+ /// it will be autogenerated. The database file is only written to disk if initialization succeeds.
161+ fn init_db ( db_file : & Path , v7_path : Option < & Path > , fs_uuid : Option < Uuid > ) -> Result < ( ) > {
156162 if db_file. try_exists ( ) ? {
157163 bail ! ( "Database file {db_file:?} already exists" ) ;
158164 }
@@ -165,7 +171,7 @@ fn init_db(db_file: &Path, v7_path: Option<&Path>) -> Result<()> {
165171
166172 let version =
167173 sqlite:: migrate_schema ( & tx, db:: MIGRATIONS ) . context ( "Creating schema failed" ) ?;
168- db:: initial_entries ( & tx) . context ( "Creating initial entries failed" ) ?;
174+ db:: initial_entries ( & tx, fs_uuid ) . context ( "Creating initial entries failed" ) ?;
169175
170176 if let Some ( v7_path) = v7_path {
171177 db:: import_v7 ( & tx, v7_path) . context ( "v7 management data import failed" ) ?;
0 commit comments