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

Calculate the database size from all files in the directory #1304

Merged
merged 2 commits into from
Nov 17, 2020

Conversation

yvonmanzi
Copy link
Contributor

@badboy, I just fixed the issue. Thanks a lot for the guidance you provided on Bugzilla. Looking forward to some feedback.

Copy link
Member

@badboy badboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is coming along nicely, but will need some adjustements.
See the inline comments.

Also please change the commit message: Calculate the database size from all files in the directory or something similar.

///
/// # Arguments
///
/// -`path` - The path to the directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// -`path` - The path to the directory
/// * `path` - The path to the directory

if let Ok(entry) = entry {
let path = entry.path();
// the getter is returning the u64 value from NonZeroU64
total_size += file_size(&path)?.get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can savae some work here. You can read the metadata of an entry directly, that one then has the len. You can then also remove the file_size function as its not used anymore.

If there's no metadata for whatever reason, we shouldn't bail out early here. If we can't read the file size of a single file, we should still read the remaining files.

///
/// # Returns
///
/// Returns the non-zero combined size of all files,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Returns the non-zero combined size of all files,
/// Returns the non-zero combined size of all files in a directory,

glean-core/src/database/mod.rs Show resolved Hide resolved
@yvonmanzi
Copy link
Contributor Author

Awesome, makes sense. Thanks for the feedback! Lemme send another PR for you to see if it all looks good.

@badboy
Copy link
Member

badboy commented Nov 13, 2020

Awesome, makes sense. Thanks for the feedback! Lemme send another PR for you to see if it all looks good.

You can update this PR (might require force-pushing to your branch)

@yvonmanzi
Copy link
Contributor Author

Hi @badboy, I am not sure why this is happening, but I see that one of the checks is failing. I'd appreciate it if you helped me figure out what the issue is. Thanks.

@badboy
Copy link
Member

badboy commented Nov 17, 2020

Hi @badboy, I am not sure why this is happening, but I see that one of the checks is failing. I'd appreciate it if you helped me figure out what the issue is. Thanks.

That seems unrelated and you can ignore it.
I somehow missed that you already pushed new code though, let me take a look.

@badboy badboy changed the title fixed Bug 1670634 Bug 1670634 - Calculate the database size from all files in the directory. Nov 17, 2020
@badboy badboy changed the title Bug 1670634 - Calculate the database size from all files in the directory. Calculate the database size from all files in the directory Nov 17, 2020
@badboy badboy merged commit 7107610 into mozilla:main Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants