|
1 | 1 | use crate::{ |
2 | 2 | args::Fraction, |
3 | | - data_tree::{DataTree, DataTreeReflection}, |
| 3 | + data_tree::DataTree, |
4 | 4 | fs_tree_builder::FsTreeBuilder, |
5 | 5 | get_size::GetSize, |
6 | 6 | hook, |
7 | | - json_data::{BinaryVersion, JsonData, SchemaVersion, UnitAndTree}, |
| 7 | + json_data::{BinaryVersion, JsonData, JsonTree, SchemaVersion, UnitAndTree}, |
8 | 8 | os_string_display::OsStringDisplay, |
9 | 9 | reporter::ParallelReporter, |
10 | 10 | runtime_error::RuntimeError, |
|
22 | 22 | Size: size::Size + Into<u64> + Serialize + Send + Sync, |
23 | 23 | SizeGetter: GetSize<Size = Size> + Copy + Sync, |
24 | 24 | Hook: hook::Hook<Size, Report> + DeduplicateHardlinkSizes<Size> + Copy + Sync, |
25 | | - DataTreeReflection<String, Size>: Into<UnitAndTree>, |
| 25 | + JsonTree<Size>: Into<UnitAndTree>, |
26 | 26 | { |
27 | 27 | /// List of files and/or directories. |
28 | 28 | pub files: Vec<PathBuf>, |
|
58 | 58 | Report: ParallelReporter<Size> + Sync, |
59 | 59 | SizeGetter: GetSize<Size = Size> + Copy + Sync, |
60 | 60 | Hook: hook::Hook<Size, Report> + DeduplicateHardlinkSizes<Size> + Copy + Sync, |
61 | | - DataTreeReflection<String, Size>: Into<UnitAndTree>, |
| 61 | + JsonTree<Size>: Into<UnitAndTree>, |
62 | 62 | { |
63 | 63 | /// Run the sub program. |
64 | 64 | pub fn run(self) -> Result<(), RuntimeError> { |
@@ -140,15 +140,18 @@ where |
140 | 140 | GLOBAL_STATUS_BOARD.clear_line(0); |
141 | 141 |
|
142 | 142 | if json_output { |
143 | | - let unit_and_tree: UnitAndTree = data_tree |
| 143 | + let data = data_tree |
144 | 144 | .into_reflection() // I really want to use std::mem::transmute here but can't. |
145 | 145 | .par_convert_names_to_utf8() // TODO: allow non-UTF8 somehow. |
146 | | - .expect("convert all names from raw string to UTF-8") |
147 | | - .into(); |
| 146 | + .expect("convert all names from raw string to UTF-8"); |
| 147 | + let json_tree = JsonTree { |
| 148 | + data, |
| 149 | + shared_inodes: None, // TODO: somehow get data from `deduplication_record` above |
| 150 | + }; |
148 | 151 | let json_data = JsonData { |
149 | 152 | schema_version: SchemaVersion, |
150 | 153 | binary_version: Some(BinaryVersion::current()), |
151 | | - unit_and_tree, |
| 154 | + unit_and_tree: json_tree.into(), |
152 | 155 | }; |
153 | 156 | return serde_json::to_writer(stdout(), &json_data) |
154 | 157 | .map_err(RuntimeError::SerializationFailure); |
|
0 commit comments