Skip to content

Commit b8651d9

Browse files
committed
fix: report hardlinks
1 parent 052952f commit b8651d9

2 files changed

Lines changed: 11 additions & 18 deletions

File tree

src/app/sub.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
data_tree::DataTree,
44
fs_tree_builder::FsTreeBuilder,
55
get_size::GetSize,
6-
hardlink::{DeduplicateSharedSize, HardlinkIgnorant, HardlinkListReflection, RecordHardlinks},
6+
hardlink::{DeduplicateSharedSize, HardlinkIgnorant, RecordHardlinks},
77
json_data::{BinaryVersion, JsonData, JsonDataBody, JsonShared, JsonTree, SchemaVersion},
88
os_string_display::OsStringDisplay,
99
reporter::ParallelReporter,
@@ -140,13 +140,10 @@ where
140140
.into_reflection() // I really want to use std::mem::transmute here but can't.
141141
.par_convert_names_to_utf8() // TODO: allow non-UTF8 somehow.
142142
.expect("convert all names from raw string to UTF-8");
143-
let details = deduplication_record
143+
let shared = deduplication_record
144144
.map_err(HardlinksHandler::convert_error)?
145-
.pipe(HardlinksHandler::serializable_report)?;
146-
let shared = JsonShared {
147-
details,
148-
summary: None, // TODO
149-
};
145+
.pipe(HardlinksHandler::serializable_report)?
146+
.unwrap_or_default();
150147
let json_tree = JsonTree { tree, shared };
151148
let json_data = JsonData {
152149
schema_version: SchemaVersion,
@@ -184,9 +181,7 @@ pub trait HardlinkSubroutines<Size: size::Size>: DeduplicateSharedSize<Size> {
184181
bytes_format: Size::DisplayFormat,
185182
) -> Result<(), RuntimeError>;
186183
/// Create a JSON serializable object from the report.
187-
fn serializable_report(
188-
report: Self::Report,
189-
) -> Result<Option<HardlinkListReflection<Size>>, RuntimeError>;
184+
fn serializable_report(report: Self::Report) -> Result<Option<JsonShared<Size>>, RuntimeError>;
190185
}
191186

192187
impl<Size> HardlinkSubroutines<Size> for HardlinkIgnorant
@@ -202,9 +197,7 @@ where
202197
Ok(())
203198
}
204199

205-
fn serializable_report(
206-
(): Self::Report,
207-
) -> Result<Option<HardlinkListReflection<Size>>, RuntimeError> {
200+
fn serializable_report((): Self::Report) -> Result<Option<JsonShared<Size>>, RuntimeError> {
208201
Ok(None)
209202
}
210203
}

src/app/sub/unix_ext.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::HardlinkSubroutines;
22
use crate::{
3-
data_tree::DataTree, hardlink::HardlinkListReflection, os_string_display::OsStringDisplay,
3+
data_tree::DataTree, json_data::JsonShared, os_string_display::OsStringDisplay,
44
runtime_error::RuntimeError, size,
55
};
66
use pipe_trait::Pipe;
@@ -25,9 +25,9 @@ where
2525
Ok(())
2626
}
2727

28-
fn serializable_report(
29-
report: Self::Report,
30-
) -> Result<Option<HardlinkListReflection<Size>>, RuntimeError> {
31-
report.into_reflection().pipe(Some).pipe(Ok)
28+
fn serializable_report(report: Self::Report) -> Result<Option<JsonShared<Size>>, RuntimeError> {
29+
let summary = report.summarize().pipe(Some);
30+
let details = report.into_reflection().pipe(Some);
31+
Ok(Some(JsonShared { details, summary }))
3232
}
3333
}

0 commit comments

Comments
 (0)