diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-12-01 20:02:13 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-12-01 20:02:13 +0800 |
| commit | f28a6f1f3460252a7e7fe4b8e4a1ef150e587f38 (patch) | |
| tree | e10b95d87827e56011a4c40bdb0a96c4a383d3e9 /src/bin | |
| parent | 36961dde3522531381dbce539a82be58bdbc82a2 (diff) | |
Replace HashMap/HashSet with BTreeMap/BTreeSet for deterministic output
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/jv.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/bin/jv.rs b/src/bin/jv.rs index 8901a94..22fbd83 100644 --- a/src/bin/jv.rs +++ b/src/bin/jv.rs @@ -1300,6 +1300,7 @@ async fn jv_here(_args: HereArgs) { let mut file_count = 0; let mut total_size = 0; + // Exists files if let Ok(mut entries) = fs::read_dir(&path).await { while let Ok(Some(entry)) = entries.next_entry().await { if let Ok(file_type) = entry.file_type().await { @@ -1464,6 +1465,7 @@ async fn jv_here(_args: HereArgs) { } } + // Remote Files for mapping in remote_files { if let Some(metadata) = mapping.1 { let mut hold = "-".to_string(); @@ -3496,18 +3498,19 @@ fn sort_paths(paths: &mut Vec<String>) { a.cmp(b) as i32 }); } + /// Get paths that exist in the Cached Sheet under the current directory fn mapping_names_here( current_dir: &PathBuf, local_dir: &PathBuf, cached_sheet: &SheetData, -) -> HashMap<String, Option<SheetMappingMetadata>> { +) -> std::collections::BTreeMap<String, Option<SheetMappingMetadata>> { let Ok(relative_path) = current_dir.strip_prefix(local_dir) else { - return HashMap::new(); + return std::collections::BTreeMap::new(); }; // Collect files directly under current directory - let files_here: HashMap<String, Option<SheetMappingMetadata>> = cached_sheet + let files_here: std::collections::BTreeMap<String, Option<SheetMappingMetadata>> = cached_sheet .mapping() .iter() .filter_map(|(f, mapping)| { @@ -3521,7 +3524,7 @@ fn mapping_names_here( .collect(); // Collect directories that appear in the mapping - let mut dirs_set = std::collections::HashSet::new(); + let mut dirs_set = std::collections::BTreeSet::new(); for (f, _mapping) in cached_sheet.mapping().iter() { // Get all parent directories of the file relative to the current directory @@ -3544,7 +3547,7 @@ fn mapping_names_here( } // Filter out directories that are actually files - let filtered_dirs: HashMap<String, Option<SheetMappingMetadata>> = dirs_set + let filtered_dirs: std::collections::BTreeMap<String, Option<SheetMappingMetadata>> = dirs_set .into_iter() .filter(|dir_with_slash| { let dir_name = dir_with_slash.trim_end_matches('/'); |
