Skip to content

Commit 222d716

Browse files
committed
Merge branch 'master' of github.com:Freaky/Compactor
2 parents 477a654 + 43ea3ba commit 222d716

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

src/backend.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<T> Backend<T> {
133133

134134
// Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
135135
fn compress_loop(&mut self) {
136-
let (send_file, send_file_rx) = bounded::<Option<(PathBuf, u64)>>(1);
136+
let (send_file, send_file_rx) = bounded::<(PathBuf, u64)>(1);
137137
let (recv_result_tx, recv_result) = bounded::<(PathBuf, io::Result<bool>)>(1);
138138

139139
let compression = Some(config().read().unwrap().current().compression);
@@ -203,7 +203,7 @@ impl<T> Backend<T> {
203203

204204
if let Some(mut fi) = folder.pop(FileKind::Compressible) {
205205
send_file
206-
.send(Some((folder.path.join(&fi.path), fi.logical_size)))
206+
.send((folder.path.join(&fi.path), fi.logical_size))
207207
.expect("send_file");
208208

209209
if !displayed && last_update.elapsed() > Duration::from_millis(50) {
@@ -291,7 +291,7 @@ impl<T> Backend<T> {
291291
}
292292
}
293293

294-
send_file.send(None).expect("send_file");
294+
drop(send_file);
295295
task.wait();
296296

297297
let _ = incompressible.save();
@@ -316,7 +316,7 @@ impl<T> Backend<T> {
316316

317317
// Oh no, not again.
318318
fn uncompress_loop(&mut self) {
319-
let (send_file, send_file_rx) = bounded::<Option<(PathBuf, u64)>>(1);
319+
let (send_file, send_file_rx) = bounded::<(PathBuf, u64)>(1);
320320
let (recv_result_tx, recv_result) = bounded::<(PathBuf, io::Result<bool>)>(1);
321321

322322
let compactor = BackgroundCompactor::new(None, send_file_rx, recv_result_tx);
@@ -380,7 +380,7 @@ impl<T> Backend<T> {
380380

381381
if let Some(mut fi) = folder.pop(FileKind::Compressed) {
382382
send_file
383-
.send(Some((folder.path.join(&fi.path), fi.logical_size)))
383+
.send((folder.path.join(&fi.path), fi.logical_size))
384384
.expect("send_file");
385385

386386
let mut waiting = false;
@@ -445,7 +445,7 @@ impl<T> Backend<T> {
445445
}
446446
}
447447

448-
send_file.send(None).expect("send_file");
448+
drop(send_file);
449449
task.wait();
450450

451451
let new_size = folder.physical_size;

src/compression.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ use crate::compact::{self, Compression};
1414
#[derive(Debug)]
1515
pub struct BackgroundCompactor {
1616
compression: Option<Compression>,
17-
files_in: Receiver<Option<(PathBuf, u64)>>,
17+
files_in: Receiver<(PathBuf, u64)>,
1818
files_out: Sender<(PathBuf, io::Result<bool>)>,
1919
}
2020

2121
impl BackgroundCompactor {
2222
pub fn new(
2323
compression: Option<Compression>,
24-
files_in: Receiver<Option<(PathBuf, u64)>>,
24+
files_in: Receiver<(PathBuf, u64)>,
2525
files_out: Sender<(PathBuf, io::Result<bool>)>,
2626
) -> Self {
2727
Self {
@@ -67,16 +67,10 @@ impl Background for BackgroundCompactor {
6767
break;
6868
}
6969

70-
match file {
71-
Some((file, _len)) => {
72-
let ret = handle_file(&file, self.compression);
73-
if self.files_out.send((file, ret)).is_err() {
74-
break;
75-
}
76-
}
77-
None => {
78-
break;
79-
}
70+
let file = file.0;
71+
let ret = handle_file(&file, self.compression);
72+
if self.files_out.send((file, ret)).is_err() {
73+
break;
8074
}
8175
}
8276
}

0 commit comments

Comments
 (0)