@@ -11,6 +11,7 @@ use std::fmt::Write;
11
11
use std:: path:: Path ;
12
12
use std:: { fs, panic} ;
13
13
use tokio:: signal:: ctrl_c;
14
+ use uuid:: Uuid ;
14
15
15
16
fn main ( ) -> Result < ( ) , i32 > {
16
17
inner_main ( ) . map_err ( |err| {
@@ -62,7 +63,11 @@ fn inner_main() -> Result<()> {
62
63
}
63
64
64
65
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
+ ) ?;
66
71
return Ok ( ( ) ) ;
67
72
}
68
73
@@ -149,10 +154,11 @@ doc.beegfs.io.",
149
154
} )
150
155
}
151
156
152
- /// Create and initialize a new database. Optionally import v7 data from the given path.
157
+ /// Create and initialize a new database.
153
158
///
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 < ( ) > {
156
162
if db_file. try_exists ( ) ? {
157
163
bail ! ( "Database file {db_file:?} already exists" ) ;
158
164
}
@@ -165,7 +171,7 @@ fn init_db(db_file: &Path, v7_path: Option<&Path>) -> Result<()> {
165
171
166
172
let version =
167
173
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" ) ?;
169
175
170
176
if let Some ( v7_path) = v7_path {
171
177
db:: import_v7 ( & tx, v7_path) . context ( "v7 management data import failed" ) ?;
0 commit comments