Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

du: use blocks to remove some cfgs #5504

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 34 additions & 31 deletions src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,39 +137,42 @@
}?;

#[cfg(not(windows))]
let file_info = FileInfo {
file_id: metadata.ino() as u128,
dev_id: metadata.dev(),
};
#[cfg(not(windows))]
return Ok(Self {
path: path.to_path_buf(),
is_dir: metadata.is_dir(),
size: if path.is_dir() { 0 } else { metadata.len() },
blocks: metadata.blocks(),
inodes: 1,
inode: Some(file_info),
created: birth_u64(&metadata),
accessed: metadata.atime() as u64,
modified: metadata.mtime() as u64,
});
{
let file_info = FileInfo {
file_id: metadata.ino() as u128,
dev_id: metadata.dev(),
};

Ok(Self {
path: path.to_path_buf(),
is_dir: metadata.is_dir(),
size: if path.is_dir() { 0 } else { metadata.len() },
blocks: metadata.blocks(),
inodes: 1,
inode: Some(file_info),
created: birth_u64(&metadata),
accessed: metadata.atime() as u64,
modified: metadata.mtime() as u64,
})
}

#[cfg(windows)]
let size_on_disk = get_size_on_disk(path);
#[cfg(windows)]
let file_info = get_file_info(path);
#[cfg(windows)]
Ok(Self {
path: path.to_path_buf(),
is_dir: metadata.is_dir(),
size: if path.is_dir() { 0 } else { metadata.len() },
blocks: size_on_disk / 1024 * 2,
inode: file_info,
inodes: 1,
created: windows_creation_time_to_unix_time(metadata.creation_time()),
accessed: windows_time_to_unix_time(metadata.last_access_time()),
modified: windows_time_to_unix_time(metadata.last_write_time()),
})
{
let size_on_disk = get_size_on_disk(path);
let file_info = get_file_info(path);

Check warning on line 162 in src/uu/du/src/du.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/du/src/du.rs#L161-L162

Added lines #L161 - L162 were not covered by tests

Ok(Self {
path: path.to_path_buf(),
is_dir: metadata.is_dir(),

Check warning on line 166 in src/uu/du/src/du.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/du/src/du.rs#L164-L166

Added lines #L164 - L166 were not covered by tests
size: if path.is_dir() { 0 } else { metadata.len() },
blocks: size_on_disk / 1024 * 2,

Check warning on line 168 in src/uu/du/src/du.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/du/src/du.rs#L168

Added line #L168 was not covered by tests
inodes: 1,
inode: file_info,
created: windows_creation_time_to_unix_time(metadata.creation_time()),
accessed: windows_time_to_unix_time(metadata.last_access_time()),
modified: windows_time_to_unix_time(metadata.last_write_time()),

Check warning on line 173 in src/uu/du/src/du.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/du/src/du.rs#L171-L173

Added lines #L171 - L173 were not covered by tests
})
}
}
}

Expand Down
Loading