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

Truncate UIDs and GIDs larger than 999999 #31

Closed
wants to merge 1 commit into from

Conversation

gregoster
Copy link

Truncate UIDs and GIDs larger than 999999 so they do not overflow the 6-character field.

@@ -245,8 +245,8 @@ impl Header {
"#1/{:<13}{:<12}{:<6}{:<6}{:<8o}{:<10}`",
padded_length,
self.mtime,
self.uid,
self.gid,
format!("{:.*}",6,self.uid.to_string()),

Choose a reason for hiding this comment

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

Since the length is fixed, you can just do {:.6} instead of .* with the 6 as a parameter. And since the writeln above already does formatting, you don't need a separate format call here. You can just change the {:<6} above to {:<6.6} and only do a self.uid.to_string() here.

Also, you can run cargo fmt to format all files according to the project settings.

Copy link
Author

Choose a reason for hiding this comment

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

This all sounds so much better :) One moment.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the suggestions. See: #32

@niklasf
Copy link
Contributor

niklasf commented Mar 27, 2024

Can be closed now (#32 landed instead).

@mdsteele mdsteele closed this Mar 28, 2024
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.

4 participants