Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit 3652aed

Browse files
author
Vanessa McHale
committed
fix parallel
1 parent c6c0e32 commit 3652aed

File tree

6 files changed

+60
-40
lines changed

6 files changed

+60
-40
lines changed

RELEASES.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

ion/bench

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# set path to include sn
44
let PATH=$HOME/.cargo/bin:$PATH
55

6-
#export CLICOLOR=0
76
let CLICOLOR=0
87

98
# set to a suitable path & decide whether to produce reports

ion/upload

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export GITHUB_TOKEN=$(cat .git-token)
77

88
let tag = $(git describe --tags)
99

10+
github-release release -u vmchale -r tin-summer --tag $tag --name @args[1..]
11+
1012
github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-x86_64-linux-gnu" --file target/release/sn
1113
github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-armv7-linux-gnueabihf" --file target/arm-unknown-linux-gnueabihf/release/sn
1214
github-release upload --user vmchale --repo tin-summer --tag $tag --name "sn-armv7-linux-musleabi" --file target/arm-unknown-linux-musleabi/release/sn

src/main.rs

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ fn main() {
5151
if !print_all {
5252
let depth = get_depth(command.value_of("depth"));
5353
w.set_depth(depth);
54-
}
55-
else if command.is_present("depth") {
56-
eprintln!("{}: flag --all is not compatible with --depth", "Warning".yellow());
54+
} else if command.is_present("depth") {
55+
eprintln!(
56+
"{}: flag --all is not compatible with --depth",
57+
"Warning".yellow()
58+
);
5759
}
5860
if print_files {
5961
w.with_files();
@@ -76,13 +78,17 @@ fn main() {
7678
};
7779

7880
// set depth
79-
let depth = if !command.is_present("all")
80-
{ Some(get_depth(command.value_of("depth"))) }
81-
else if command.is_present("depth") {
82-
eprintln!("{}: flag --all is not compatible with --depth", "Warning".yellow());
81+
let depth = if !command.is_present("all") {
82+
Some(get_depth(command.value_of("depth")))
83+
} else if command.is_present("depth") {
84+
eprintln!(
85+
"{}: flag --all is not compatible with --depth",
86+
"Warning".yellow()
87+
);
8388
None
84-
}
85-
else { None };
89+
} else {
90+
None
91+
};
8692

8793
// don't print warnings
8894
//let silent = command.is_present("silent");
@@ -126,13 +132,17 @@ fn main() {
126132
let min_bytes = threshold(command.value_of("threshold"));
127133

128134
// set depth
129-
let depth = if !command.is_present("all")
130-
{ Some(get_depth(command.value_of("depth"))) }
131-
else if command.is_present("depth") {
132-
eprintln!("{}: flag --all is not compatible with --depth", "Warning".yellow());
135+
let depth = if !command.is_present("all") {
136+
Some(get_depth(command.value_of("depth")))
137+
} else if command.is_present("depth") {
138+
eprintln!(
139+
"{}: flag --all is not compatible with --depth",
140+
"Warning".yellow()
141+
);
133142
None
134-
}
135-
else { None };
143+
} else {
144+
None
145+
};
136146

137147
// set regex for exclusions
138148
let regex = command.value_of("excludes");
@@ -173,13 +183,17 @@ fn main() {
173183
let min_bytes = threshold(command.value_of("threshold"));
174184

175185
// set depth
176-
let depth = if !command.is_present("all")
177-
{ Some(get_depth(command.value_of("depth"))) }
178-
else if command.is_present("depth") {
179-
eprintln!("{}: flag --all is not compatible with --depth", "Warning".yellow());
186+
let depth = if !command.is_present("all") {
187+
Some(get_depth(command.value_of("depth")))
188+
} else if command.is_present("depth") {
189+
eprintln!(
190+
"{}: flag --all is not compatible with --depth",
191+
"Warning".yellow()
192+
);
180193
None
181-
}
182-
else { None };
194+
} else {
195+
None
196+
};
183197

184198
// set number of things to fetch for sort
185199
let num_int = get_num(command.value_of("count"));
@@ -245,13 +259,17 @@ fn main() {
245259
let num_int = get_num(command.value_of("count"));
246260

247261
// set depth
248-
let depth = if !command.is_present("all")
249-
{ Some(get_depth(command.value_of("depth"))) }
250-
else if command.is_present("depth") {
251-
eprintln!("{}: flag --all is not compatible with --depth", "Warning".yellow());
262+
let depth = if !command.is_present("all") {
263+
Some(get_depth(command.value_of("depth")))
264+
} else if command.is_present("depth") {
265+
eprintln!(
266+
"{}: flag --all is not compatible with --depth",
267+
"Warning".yellow()
268+
);
252269
None
253-
}
254-
else { None };
270+
} else {
271+
None
272+
};
255273

256274
// set whether to print files too
257275
let print_files = command.is_present("files");

src/walk_parallel/mod.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Walk {
7575

7676
if to_print {
7777
// filter by depth
78-
let mut v_filtered = v.filtered(w.threshold, w.show_files, w.max_depth);
78+
let mut v_filtered = v.filtered(w.threshold, !w.show_files, w.max_depth);
7979

8080
v_filtered.display_tree(w.path);
8181
}
@@ -174,6 +174,9 @@ impl Walk {
174174
let mut new_path = w.path.to_owned();
175175
new_path.push(val.file_name());
176176
let mut new_walk = Walk::new(new_path, w.get_proc());
177+
if w.show_files {
178+
new_walk.with_files();
179+
}
177180
new_walk.bump_depth();
178181
if let Some(d) = w.max_depth {
179182
new_walk.set_depth(d);
@@ -186,11 +189,13 @@ impl Walk {
186189
if let Ok(l) = val.metadata() {
187190
let size = l.len();
188191
total.fetch_add(size, Ordering::Relaxed);
189-
if w.show_files {
190-
if size != 0 {
191-
let to_formatted = format!("{}", FileSize::new(size));
192-
println!("{}\t {}", &to_formatted.green(), val.path().display());
193-
}
192+
if w.show_files && size != 0 {
193+
let to_formatted = format!("{}", FileSize::new(size));
194+
println!(
195+
"{}\t {}",
196+
&to_formatted.green(),
197+
val.path().display()
198+
);
194199
}
195200
} else {
196201
eprintln!(
@@ -322,7 +327,7 @@ pub fn print_parallel(w: Walk) -> () {
322327
let _ = threads.into_iter().map(|v| v.join().unwrap()).count();
323328

324329
// get the total size
325-
let m = arc.load(Ordering::SeqCst);
330+
let m = arc.load(Ordering::SeqCst); // TODO - check if this works with Relaxed?
326331
let size = FileSize::new(m);
327332

328333
// print directory total.

src/walk_parallel/single_threaded.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,7 @@ pub fn read_all(
404404
true,
405405
);
406406
}
407-
}
408-
else {
407+
} else {
409408
let mut subtree = read_all(
410409
&path,
411410
depth + 1,

0 commit comments

Comments
 (0)