mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #683 from samfoo/fix-futures-in-du
Fix build by making du not use futures
This commit is contained in:
commit
239443a253
1 changed files with 11 additions and 5 deletions
16
src/du/du.rs
16
src/du/du.rs
|
@ -1,5 +1,4 @@
|
||||||
#![crate_name = "du"]
|
#![crate_name = "du"]
|
||||||
#![feature(future)]
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the uutils coreutils package.
|
* This file is part of the uutils coreutils package.
|
||||||
|
@ -20,8 +19,10 @@ use std::fs;
|
||||||
use std::io::{stderr, Write};
|
use std::io::{stderr, Write};
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::{Arc, Future};
|
use std::sync::Arc;
|
||||||
use time::Timespec;
|
use time::Timespec;
|
||||||
|
use std::sync::mpsc::channel;
|
||||||
|
use std::thread;
|
||||||
|
|
||||||
#[path = "../common/util.rs"]
|
#[path = "../common/util.rs"]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -85,7 +86,12 @@ fn du(path: &PathBuf, mut my_stat: Stat, options: Arc<Options>, depth: usize) ->
|
||||||
let this_stat = Stat::new(&entry.path());
|
let this_stat = Stat::new(&entry.path());
|
||||||
if this_stat.is_dir {
|
if this_stat.is_dir {
|
||||||
let oa_clone = options.clone();
|
let oa_clone = options.clone();
|
||||||
futures.push(Future::spawn(move || { du(&entry.path(), this_stat, oa_clone, depth + 1) }))
|
let (tx, rx) = channel();
|
||||||
|
thread::spawn(move || {
|
||||||
|
let result = du(&entry.path(), this_stat, oa_clone, depth + 1);
|
||||||
|
tx.send(result)
|
||||||
|
});
|
||||||
|
futures.push(rx);
|
||||||
} else {
|
} else {
|
||||||
my_stat.size += this_stat.size;
|
my_stat.size += this_stat.size;
|
||||||
my_stat.blocks += this_stat.blocks;
|
my_stat.blocks += this_stat.blocks;
|
||||||
|
@ -96,8 +102,8 @@ fn du(path: &PathBuf, mut my_stat: Stat, options: Arc<Options>, depth: usize) ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for future in futures.iter_mut() {
|
for rx in futures.iter_mut() {
|
||||||
for stat in future.get().into_iter().rev() {
|
for stat in rx.recv().unwrap().into_iter().rev() {
|
||||||
if !options.separate_dirs && stat.path.parent().unwrap().to_path_buf() == my_stat.path {
|
if !options.separate_dirs && stat.path.parent().unwrap().to_path_buf() == my_stat.path {
|
||||||
my_stat.size += stat.size;
|
my_stat.size += stat.size;
|
||||||
my_stat.blocks += stat.blocks;
|
my_stat.blocks += stat.blocks;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue