mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Moved sync outside of filesystem calls
This commit is contained in:
+8
-8
@@ -295,15 +295,8 @@ fn is_best(previous: &[MountInfo], mi: &MountInfo) -> bool {
|
||||
|
||||
/// Get all currently mounted filesystems.
|
||||
///
|
||||
/// `opt` excludes certain filesystems from consideration and allows for the synchronization of filesystems before running; see
|
||||
/// [`Options`] for more information.
|
||||
/// `opt` excludes certain filesystems from consideration; see [`Options`] for more information.
|
||||
fn get_all_filesystems(opt: &Options) -> UResult<Vec<Filesystem>> {
|
||||
// Run a sync call before any operation if so instructed.
|
||||
if opt.sync {
|
||||
#[cfg(not(any(windows, target_os = "redox")))]
|
||||
rustix::fs::sync();
|
||||
}
|
||||
|
||||
let mut mounts = vec![];
|
||||
for mut mi in read_fs_list()? {
|
||||
// TODO The running time of the `is_best()` function is linear
|
||||
@@ -450,6 +443,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
}
|
||||
|
||||
let opt = Options::from(&matches).map_err(DfError::OptionsError)?;
|
||||
|
||||
// Run a sync call before any operation if so instructed.
|
||||
if opt.sync {
|
||||
#[cfg(not(any(windows, target_os = "redox")))]
|
||||
rustix::fs::sync();
|
||||
}
|
||||
|
||||
// Get the list of filesystems to display in the output table.
|
||||
let filesystems: Vec<Filesystem> = match matches.get_many::<OsString>(OPT_PATHS) {
|
||||
None => {
|
||||
|
||||
Reference in New Issue
Block a user