Skip to content

[fileutil] use 0755 as default filemode to create dir #1103

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

Merged
merged 1 commit into from
Jun 7, 2023

Conversation

hezhizhen
Copy link
Contributor

Summary

Use 0755 as default filemode to create dir. If dir exists, use its own filemode to recreate.

How was it tested?

@hezhizhen hezhizhen marked this pull request as ready for review June 6, 2023 15:08
f, err := os.Stat(dir)
if err != nil {
return errors.WithStack(err)
if err == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we preserve returning an error unless it is fs.ErrNotExist?

var mode os.FileMode
if f, err := os.Stat(dir); if err == nil {
      mode = f.Mode()
} else if errors.Is(err, fs.ErrNotExist) {
         mode = 0755
else {
 	return errors.WithStack(err)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@savil savil requested a review from mikeland73 June 7, 2023 02:55
Copy link
Collaborator

@savil savil left a comment

Choose a reason for hiding this comment

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

thanks!

@savil savil merged commit 7223bef into jetify-com:main Jun 7, 2023
@hezhizhen hezhizhen deleted the cleardir-2 branch August 9, 2023 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants