-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: implementation of file size formatting (#379)
This PR removes `src/utils/fmt.rs`, since it only had the `format_bytes` function, which can also be used from another library. The implementation of `format_bytes` is also incorrect. `1024 bytes` is not equal to `1KB`, as the test indicates. `1024 bytes` is equal to `1KiB`, and means `Kibibyte`, where `bi` stands for binary. Why not just use a library for that? That would eliminate such bugs. The PR changes the file size type from `String` to `u64` and adds a `_bytes` postfix to the property name. ```diff - pub(crate) size: String, + pub(crate) size_bytes: u64, ``` I would love to store the file size as the `Size` struct provided by the `size` crate and remove the postfix, but `Size` doesn't implement the `Serialize` trait, and we'd have to wait for that before we can do that. --------- Co-authored-by: Esteban Borai <[email protected]>
- Loading branch information
1 parent
70fc494
commit 5f8796e
Showing
7 changed files
with
31 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
pub mod error; | ||
pub mod fmt; | ||
pub mod signal; | ||
pub mod url_encode; |