mirror of
https://github.com/132nd-vWing/tacview-splitter.git
synced 2026-08-26 07:38:37 +02:00
clean up save_to_disk by cloning OutputData
This commit is contained in:
+17
-12
@@ -98,6 +98,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct OutputData {
|
pub struct OutputData {
|
||||||
input_filename: Arc<String>,
|
input_filename: Arc<String>,
|
||||||
is_zip: bool,
|
is_zip: bool,
|
||||||
@@ -137,24 +138,28 @@ impl OutputData {
|
|||||||
let handles: Vec<_> = coalitions
|
let handles: Vec<_> = coalitions
|
||||||
.iter()
|
.iter()
|
||||||
.map(|coalition| {
|
.map(|coalition| {
|
||||||
let z = self.is_zip;
|
let thread_self = self.clone();
|
||||||
let b = self.body.clone();
|
let thread_coalition = coalition.clone();
|
||||||
let cpl = self.coalition_per_line.clone();
|
|
||||||
let c = coalition.clone();
|
|
||||||
let h = self.header.clone();
|
|
||||||
let i = self.input_filename.clone();
|
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let mut writer = create_writer(z, &i.clone(), &c)
|
let mut writer = create_writer(
|
||||||
.with_context(|| format!("could not create writer for {c}"))
|
thread_self.is_zip,
|
||||||
|
&thread_self.input_filename,
|
||||||
|
&thread_coalition,
|
||||||
|
)
|
||||||
|
.with_context(|| format!("could not create writer for {thread_coalition}"))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
writer
|
writer
|
||||||
.write_strings(&h)
|
.write_strings(&thread_self.header)
|
||||||
.with_context(|| format!("could not write header for {c}"))
|
.with_context(|| format!("could not write header for {thread_coalition}"))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
writer
|
writer
|
||||||
.write_for_coalition(&b, &cpl, &c)
|
.write_for_coalition(
|
||||||
.with_context(|| format!("could not write body for {c}"))
|
&thread_self.body,
|
||||||
|
&thread_self.coalition_per_line,
|
||||||
|
&thread_coalition,
|
||||||
|
)
|
||||||
|
.with_context(|| format!("could not write body for {thread_coalition}"))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user