diff --git a/crates/memofs/src/std_backend.rs b/crates/memofs/src/std_backend.rs index 04e78548..cd0c5411 100644 --- a/crates/memofs/src/std_backend.rs +++ b/crates/memofs/src/std_backend.rs @@ -344,7 +344,7 @@ impl VfsBackend for StdBackend { // This prevents a failed watch from permanently marking the path as "watched" match self.debouncer.watch(path, RecursiveMode::Recursive) { Ok(()) => { - log::info!("Watching path: {}", path.display()); + log::debug!("Watching path: {}", path.display()); self.watches.insert(path.to_path_buf()); Ok(()) } diff --git a/src/cli/sourcemap.rs b/src/cli/sourcemap.rs index 3c103dd7..0ec05686 100644 --- a/src/cli/sourcemap.rs +++ b/src/cli/sourcemap.rs @@ -182,22 +182,28 @@ fn patch_set_affects_sourcemap( fn recurse_create_node<'a>( tree: &'a RojoTree, referent: Ref, - project_dir: &Path, + canonical_project_dir: &Path, filter: fn(&InstanceWithMeta) -> bool, use_absolute_paths: bool, ) -> Option> { let instance = tree.get_instance(referent).expect("instance did not exist"); - let children: Vec<_> = instance + let results: Vec>> = instance .children() .par_iter() - .filter_map(|&child_id| { - recurse_create_node(tree, child_id, project_dir, filter, use_absolute_paths) + .map(|&child_id| { + recurse_create_node( + tree, + child_id, + canonical_project_dir, + filter, + use_absolute_paths, + ) }) .collect(); - // If this object has no children and doesn't pass the filter, it doesn't - // contain any information we're looking for. + let children: Vec<_> = results.into_iter().flatten().collect(); + if children.is_empty() && !filter(&instance) { return None; } @@ -206,25 +212,19 @@ fn recurse_create_node<'a>( .metadata() .relevant_paths .iter() - // Not all paths listed as relevant are guaranteed to exist. .filter(|path| path.is_file()) .map(|path| path.as_path()); let mut output_file_paths: Vec> = Vec::with_capacity(instance.metadata().relevant_paths.len()); - // Canonicalize project_dir once to normalize Windows \\?\ prefixes - let canonical_project_dir = - std::fs::canonicalize(project_dir).unwrap_or_else(|_| project_dir.to_path_buf()); - for val in file_paths { if use_absolute_paths { let abs_path = path::absolute(val).expect(ABSOLUTE_PATH_FAILED_ERR); output_file_paths.push(Cow::Owned(abs_path)); } else { - let canonical_val = std::fs::canonicalize(val).unwrap_or_else(|_| val.to_path_buf()); output_file_paths.push(Cow::Owned( - pathdiff::diff_paths(&canonical_val, &canonical_project_dir) + pathdiff::diff_paths(val, canonical_project_dir) .expect("Failed to compute relative path from project dir"), )); } @@ -247,10 +247,13 @@ pub(crate) fn write_sourcemap( ) -> anyhow::Result<()> { let tree = session.tree(); + let canonical_project_dir = std::fs::canonicalize(session.root_dir()) + .unwrap_or_else(|_| session.root_dir().to_path_buf()); + let root_node = recurse_create_node( &tree, tree.get_root_id(), - session.root_dir(), + &canonical_project_dir, filter, use_absolute_paths, ); @@ -324,10 +327,7 @@ fn recurse_create_node_from_dom<'a>( .map(|paths| { paths .iter() - .filter_map(|p| { - let canonical = std::fs::canonicalize(p).unwrap_or_else(|_| p.clone()); - pathdiff::diff_paths(&canonical, project_dir).map(Cow::Owned) - }) + .filter_map(|p| pathdiff::diff_paths(p, project_dir).map(Cow::Owned)) .collect() }) .unwrap_or_default(); diff --git a/src/rojo_ref.rs b/src/rojo_ref.rs index 6e923fa6..dc6ac271 100644 --- a/src/rojo_ref.rs +++ b/src/rojo_ref.rs @@ -428,7 +428,7 @@ impl RefPathIndex { } if count > 0 { - log::info!( + log::debug!( "RefPathIndex: populated {} Rojo_Ref_* entries from existing meta/model files", count ); diff --git a/src/serve_session.rs b/src/serve_session.rs index fd16b299..6bd5ddf0 100644 --- a/src/serve_session.rs +++ b/src/serve_session.rs @@ -174,7 +174,7 @@ fn prefetch_project_files(project: &Project) -> io::Result { let file_count = entries.iter().filter(|e| e.file_type().is_file()).count(); let dir_count = entries.len() - file_count; - log::info!( + log::debug!( "Prefetch walk: {} files + {} dirs from {} root(s) in {:.1?}", file_count, dir_count, @@ -206,7 +206,7 @@ fn prefetch_project_files(project: &Project) -> io::Result { let canon_elapsed = canon_start.elapsed(); - log::info!( + log::debug!( "Prefetch I/O: read {} files in {:.1?}, canonicalize {} paths in {:.1?}", file_data.len(), read_elapsed, @@ -235,7 +235,7 @@ fn prefetch_project_files(project: &Project) -> io::Result { children.sort_by(|a, b| a.file_name().cmp(&b.file_name())); } - log::info!( + log::debug!( "Prefetch maps: {} is_file + {} children dirs built", is_file_map.len(), children_map.len(), @@ -293,7 +293,7 @@ impl ServeSession { let snap_start = Instant::now(); log::trace!("Generating snapshot of instances from VFS"); let snapshot = snapshot_from_vfs(&instance_context, vfs, start_path)?; - log::info!("Snapshot built in {:.1?}", snap_start.elapsed()); + log::debug!("Snapshot built in {:.1?}", snap_start.elapsed()); vfs.clear_prefetch_cache(); @@ -303,7 +303,7 @@ impl ServeSession { log::trace!("Applying initial patch set"); apply_patch_set(&mut tree, patch_set); - log::info!("Patch computed + applied in {:.1?}", patch_start.elapsed()); + log::debug!("Patch computed + applied in {:.1?}", patch_start.elapsed()); Ok((root_project, tree)) } diff --git a/src/syncback/mod.rs b/src/syncback/mod.rs index ebcf0063..1ad47f54 100644 --- a/src/syncback/mod.rs +++ b/src/syncback/mod.rs @@ -132,7 +132,7 @@ pub fn syncback_loop_with_stats( // (references to instances that will be pruned, like SoundGroups in SoundService). log::debug!("Collecting instance paths before pruning..."); let pre_prune_paths = collect_all_paths(&new_tree); - log::info!( + log::debug!( "syncback: collect_all_paths in {:.1?}", phase_timer.elapsed() ); @@ -171,12 +171,12 @@ pub fn syncback_loop_with_stats( if ignore_hidden { strip_hidden_services(&mut new_tree); } - log::info!("syncback: prune + filter in {:.1?}", phase_timer.elapsed()); + log::debug!("syncback: prune + filter in {:.1?}", phase_timer.elapsed()); let phase_timer = std::time::Instant::now(); let mut deferred_referents = collect_referents(&new_tree, &pre_prune_paths, None); let placeholder_map = std::mem::take(&mut deferred_referents.placeholder_to_source_and_target); - log::info!( + log::debug!( "syncback: collect_referents in {:.1?}", phase_timer.elapsed() ); @@ -235,7 +235,7 @@ pub fn syncback_loop_with_stats( if !ignore_referents { link_referents(deferred_referents, &mut new_tree)?; } - log::info!( + log::debug!( "syncback: filter props + link refs in {:.1?}", phase_timer.elapsed() ); @@ -247,7 +247,7 @@ pub fn syncback_loop_with_stats( || hash_tree(project, old_tree.inner(), old_tree.get_root_id()), || hash_tree(project, &new_tree, new_tree.root_ref()), ); - log::info!( + log::debug!( "syncback: hash both trees (parallel) in {:.1?}", phase_timer.elapsed() ); @@ -381,13 +381,13 @@ pub fn syncback_loop_with_stats( } } - log::trace!( - "dirs_to_scan: {:?}", - dirs_to_scan + if log::log_enabled!(log::Level::Trace) { + let dirs_str: Vec<_> = dirs_to_scan .iter() .map(|p| p.display().to_string()) - .collect::>() - ); + .collect(); + log::trace!("dirs_to_scan: {:?}", dirs_str); + } for dir in &dirs_to_scan { if !dir.is_dir() { @@ -439,7 +439,7 @@ pub fn syncback_loop_with_stats( } else { HashSet::new() }; - log::info!( + log::debug!( "syncback: orphan scan in {:.1?} ({} paths)", phase_timer.elapsed(), existing_paths.len() @@ -605,7 +605,7 @@ pub fn syncback_loop_with_stats( snapshots.extend(syncback.children); } - log::info!("syncback: main walk loop in {:.1?}", phase_timer.elapsed()); + log::debug!("syncback: main walk loop in {:.1?}", phase_timer.elapsed()); let phase_timer = std::time::Instant::now(); { @@ -625,7 +625,7 @@ pub fn syncback_loop_with_stats( let relative = crate::compute_relative_ref_path(&source_abs, &target_abs); substitutions.push((placeholder.clone(), relative)); } - log::info!( + log::debug!( "syncback: built {} ref substitutions in {:.1?}", substitutions.len(), phase_timer.elapsed() @@ -635,7 +635,7 @@ pub fn syncback_loop_with_stats( if !substitutions.is_empty() { fs_snapshot.fix_ref_paths(&substitutions); } - log::info!( + log::debug!( "syncback: applied ref substitutions in {:.1?}", sub_timer.elapsed() ); @@ -738,8 +738,10 @@ pub fn syncback_loop_with_stats( &mut protected_paths, &mut path_to_instance_prefix, ); - log::trace!("Protected $path references: {:?}", protected_paths); - log::trace!("Path to instance mappings: {:?}", path_to_instance_prefix); + if log::log_enabled!(log::Level::Trace) { + log::trace!("Protected $path references: {:?}", protected_paths); + log::trace!("Path to instance mappings: {:?}", path_to_instance_prefix); + } // Helper to convert a filesystem path to an instance path using the mappings let fs_path_to_instance_path = |fs_path: &Path| -> Option { @@ -906,7 +908,7 @@ pub fn syncback_loop_with_stats( } } - log::info!("syncback: orphan removal in {:.1?}", phase_timer.elapsed()); + log::debug!("syncback: orphan removal in {:.1?}", phase_timer.elapsed()); if external_stats.is_none() { stats.log_summary();