@@ -4,7 +4,7 @@ use ahash::{HashMap, HashMapExt};
4
4
use re_log_types:: { FileSource , LogMsg } ;
5
5
use re_smart_channel:: Sender ;
6
6
7
- use crate :: { DataLoaderError , LoadedData } ;
7
+ use crate :: { DataLoader , DataLoaderError , LoadedData , RrdLoader } ;
8
8
9
9
// ---
10
10
@@ -37,7 +37,7 @@ pub fn load_from_path(
37
37
38
38
let rx = load ( settings, path, None ) ?;
39
39
40
- send ( settings. clone ( ) , file_source, path . to_owned ( ) , rx, tx) ;
40
+ send ( settings. clone ( ) , file_source, rx, tx) ;
41
41
42
42
Ok ( ( ) )
43
43
}
@@ -64,7 +64,7 @@ pub fn load_from_file_contents(
64
64
65
65
let data = load ( settings, filepath, Some ( contents) ) ?;
66
66
67
- send ( settings. clone ( ) , file_source, filepath . to_owned ( ) , data, tx) ;
67
+ send ( settings. clone ( ) , file_source, data, tx) ;
68
68
69
69
Ok ( ( ) )
70
70
}
@@ -73,21 +73,20 @@ pub fn load_from_file_contents(
73
73
74
74
/// Prepares an adequate [`re_log_types::StoreInfo`] [`LogMsg`] given the input.
75
75
pub ( crate ) fn prepare_store_info (
76
+ application_id : re_log_types:: ApplicationId ,
76
77
store_id : & re_log_types:: StoreId ,
77
78
file_source : FileSource ,
78
- path : & std:: path:: Path ,
79
79
) -> LogMsg {
80
- re_tracing:: profile_function!( path . display ( ) . to_string ( ) ) ;
80
+ re_tracing:: profile_function!( ) ;
81
81
82
82
use re_log_types:: SetStoreInfo ;
83
83
84
- let app_id = re_log_types:: ApplicationId ( path. display ( ) . to_string ( ) ) ;
85
84
let store_source = re_log_types:: StoreSource :: File { file_source } ;
86
85
87
86
LogMsg :: SetStoreInfo ( SetStoreInfo {
88
87
row_id : * re_chunk:: RowId :: new ( ) ,
89
88
info : re_log_types:: StoreInfo {
90
- application_id : app_id . clone ( ) ,
89
+ application_id,
91
90
store_id : store_id. clone ( ) ,
92
91
cloned_from : None ,
93
92
is_official_example : false ,
@@ -263,14 +262,19 @@ pub(crate) fn load(
263
262
pub ( crate ) fn send (
264
263
settings : crate :: DataLoaderSettings ,
265
264
file_source : FileSource ,
266
- path : std:: path:: PathBuf ,
267
265
rx_loader : std:: sync:: mpsc:: Receiver < LoadedData > ,
268
266
tx : & Sender < LogMsg > ,
269
267
) {
270
268
spawn ( {
271
269
re_tracing:: profile_function!( ) ;
272
270
273
- let mut store_info_tracker: HashMap < re_log_types:: StoreId , bool > = HashMap :: new ( ) ;
271
+ #[ derive( Default , Debug ) ]
272
+ struct Tracked {
273
+ is_rrd_or_rbl : bool ,
274
+ already_has_store_info : bool ,
275
+ }
276
+
277
+ let mut store_info_tracker: HashMap < re_log_types:: StoreId , Tracked > = HashMap :: new ( ) ;
274
278
275
279
let tx = tx. clone ( ) ;
276
280
move || {
@@ -280,6 +284,7 @@ pub(crate) fn send(
280
284
// poll the channel in any case so as to make sure that the data producer
281
285
// doesn't get stuck.
282
286
for data in rx_loader {
287
+ let data_loader_name = data. data_loader_name ( ) . clone ( ) ;
283
288
let msg = match data. into_log_msg ( ) {
284
289
Ok ( msg) => {
285
290
let store_info = match & msg {
@@ -293,7 +298,10 @@ pub(crate) fn send(
293
298
} ;
294
299
295
300
if let Some ( ( store_id, store_info_created) ) = store_info {
296
- * store_info_tracker. entry ( store_id) . or_default ( ) |= store_info_created;
301
+ let tracked = store_info_tracker. entry ( store_id) . or_default ( ) ;
302
+ tracked. is_rrd_or_rbl =
303
+ * data_loader_name == RrdLoader :: name ( & RrdLoader ) ;
304
+ tracked. already_has_store_info |= store_info_created;
297
305
}
298
306
299
307
msg
@@ -306,16 +314,25 @@ pub(crate) fn send(
306
314
tx. send ( msg) . ok ( ) ;
307
315
}
308
316
309
- for ( store_id, store_info_already_created ) in store_info_tracker {
317
+ for ( store_id, tracked ) in store_info_tracker {
310
318
let is_a_preexisting_recording =
311
319
Some ( & store_id) == settings. opened_store_id . as_ref ( ) ;
312
320
313
- if store_info_already_created || is_a_preexisting_recording {
314
- continue ;
315
- }
321
+ // Never try to send custom store info for RRDs and RBLs, they always have their own, and
322
+ // it's always right.
323
+ let should_force_store_info = !tracked. is_rrd_or_rbl && settings. force_store_info ;
324
+
325
+ let should_send_new_store_info = should_force_store_info
326
+ || ( !tracked. already_has_store_info && !is_a_preexisting_recording) ;
316
327
317
- let store_info = prepare_store_info ( & store_id, file_source. clone ( ) , & path) ;
318
- tx. send ( store_info) . ok ( ) ;
328
+ if should_send_new_store_info {
329
+ let app_id = settings
330
+ . opened_application_id
331
+ . clone ( )
332
+ . unwrap_or_else ( || uuid:: Uuid :: new_v4 ( ) . to_string ( ) . into ( ) ) ;
333
+ let store_info = prepare_store_info ( app_id, & store_id, file_source. clone ( ) ) ;
334
+ tx. send ( store_info) . ok ( ) ;
335
+ }
319
336
}
320
337
321
338
tx. quit ( None ) . ok ( ) ;
0 commit comments