Skip to content

Commit 840d182

Browse files
committed
fix(json): move "shared-inodes" out of "tree"
1 parent bbba73c commit 840d182

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ impl App {
8686
}
8787

8888
let visualization = match unit_and_tree {
89-
UnitAndTree::Bytes(tree) => visualize!(tree.data, bytes_format),
90-
UnitAndTree::Blocks(tree) => visualize!(tree.data, ()),
89+
UnitAndTree::Bytes(tree) => visualize!(tree.tree, bytes_format),
90+
UnitAndTree::Blocks(tree) => visualize!(tree.tree, ()),
9191
};
9292

9393
print!("{visualization}"); // it already ends with "\n", println! isn't needed here.

src/app/sub.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ where
142142
GLOBAL_STATUS_BOARD.clear_line(0);
143143

144144
if json_output {
145-
let data = data_tree
145+
let tree = data_tree
146146
.into_reflection() // I really want to use std::mem::transmute here but can't.
147147
.par_convert_names_to_utf8() // TODO: allow non-UTF8 somehow.
148148
.expect("convert all names from raw string to UTF-8");
149149
let shared_inodes = deduplication_record?.pipe(Hook::reflect_deduplication_results)?;
150150
let json_tree = JsonTree {
151-
data,
151+
tree,
152152
shared_inodes,
153153
};
154154
let json_data = JsonData {

src/json_data.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ pub struct JsonTree<Size: size::Size> {
2222
/// The main data of the tree.
2323
#[deref]
2424
#[deref_mut]
25-
#[cfg_attr(feature = "json", serde(flatten))]
26-
pub data: DataTreeReflection<String, Size>,
25+
pub tree: DataTreeReflection<String, Size>,
2726
/// Optional list of shared inodes, their sizes, and their many links.
2827
#[cfg_attr(feature = "json", serde(skip_serializing_if = "Option::is_none"))]
2928
pub shared_inodes: Option<HardlinkListReflection<Size>>,
@@ -32,7 +31,7 @@ pub struct JsonTree<Size: size::Size> {
3231
/// The `"unit"` field and the `"tree"` field of [`JsonData`].
3332
#[derive(Debug, Clone, From, TryInto)]
3433
#[cfg_attr(feature = "json", derive(Deserialize, Serialize))]
35-
#[cfg_attr(feature = "json", serde(tag = "unit", content = "tree"))]
34+
#[cfg_attr(feature = "json", serde(tag = "unit"))]
3635
#[cfg_attr(feature = "json", serde(rename_all = "kebab-case"))]
3736
pub enum UnitAndTree {
3837
/// Tree where size is [bytes](Bytes).

tests/json.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn json_output() {
7777
.unit_and_tree
7878
.pipe(TryInto::<SampleJsonTree>::try_into)
7979
.expect("extract reflection")
80-
.data
80+
.tree
8181
.pipe(sanitize_tree_reflection);
8282
dbg!(&actual);
8383
let builder = FsTreeBuilder {
@@ -100,7 +100,7 @@ fn json_output() {
100100
#[test]
101101
fn json_input() {
102102
let json_tree = JsonTree {
103-
data: sample_tree().into_reflection(),
103+
tree: sample_tree().into_reflection(),
104104
shared_inodes: None,
105105
};
106106
let json_data = JsonData {

0 commit comments

Comments
 (0)