Skip to content

Commit

Permalink
fix: new file permissions on generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Oct 30, 2024
1 parent 73bb5c4 commit db2581e
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion cmd/spawn/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ func AddModuleToAppGo(logger *slog.Logger, extName string, feats *features) erro
logger.Debug("initParamsKeeper register", "extName", extName, "start", start, "end", end)
appGoLines = append(appGoLines[:end-3], append([]string{fmt.Sprintf(` paramsKeeper.Subspace(%stypes.ModuleName)`, extName)}, appGoLines[end-3:]...)...)

return os.WriteFile(appGoPath, []byte(strings.Join(appGoLines, "\n")), 0644)
// 777 is used as some users have weird setup / group environments w/ MacOS. 766 is more ideal but .sh files need to be executed.
return os.WriteFile(appGoPath, []byte(strings.Join(appGoLines, "\n")), 0777)
}

// appendNewImportsToSource appends new imports to the source file at the end of the import block (before the closing `)` ).
Expand Down
2 changes: 1 addition & 1 deletion spawn/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func debugErrorFile(logger *slog.Logger, newDirname string) string {
}

fullPath := path.Join(debugDir, fname)
if err := os.WriteFile(fullPath, []byte(errFileText), 0644); err != nil {
if err := os.WriteFile(fullPath, []byte(errFileText), 0766); err != nil {
logger.Error("Error saving debug file", "err", err)
}

Expand Down
5 changes: 3 additions & 2 deletions spawn/file_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,10 @@ func (fc *FileContent) Save() error {
return nil
}

if err := os.MkdirAll(path.Dir(fc.NewPath), 0755); err != nil {
// 777 is used as some users have weird setup / group environments w/ MacOS. 766 is more ideal but .sh files need to be executed.
if err := os.MkdirAll(path.Dir(fc.NewPath), 0777); err != nil {
return err
}

return os.WriteFile(fc.NewPath, []byte(fc.Contents), 0644)
return os.WriteFile(fc.NewPath, []byte(fc.Contents), 0777)
}
2 changes: 1 addition & 1 deletion spawn/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ func (mf MetadataFile) SaveJSON(loc string) error {
return err
}

return os.WriteFile(loc, bz, 0644)
return os.WriteFile(loc, bz, 0666)
}
2 changes: 1 addition & 1 deletion spawn/proto_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func ApplyMissingRPCMethodsToGoSourceFiles(logger *slog.Logger, missingRPCMethod
// append to the file content after a new line at the end
content = append(content, []byte("\n"+code)...)

if err := os.WriteFile(fileLoc, content, 0644); err != nil {
if err := os.WriteFile(fileLoc, content, 0666); err != nil {
logger.Error("error", "err", err)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion spawn/types/chain_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,5 @@ func (v ChainRegistryFormat) SaveJSON(loc string) error {
return err
}

return os.WriteFile(loc, bz, 0644)
return os.WriteFile(loc, bz, 0666)
}
2 changes: 1 addition & 1 deletion spawn/types/chain_registry_assets_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ func (v ChainRegistryAssetsList) SaveJSON(loc string) error {
return err
}

return os.WriteFile(loc, bz, 0644)
return os.WriteFile(loc, bz, 0666)
}
4 changes: 2 additions & 2 deletions spawn/version_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func DoOutdatedNotificationRunCheck(logger *slog.Logger) bool {
}

func WriteLastTimeToFile(logger *slog.Logger, lastCheckFile string, t time.Time) error {
return os.WriteFile(lastCheckFile, []byte(t.Format(time.RFC3339)), 0644)
return os.WriteFile(lastCheckFile, []byte(t.Format(time.RFC3339)), 0666)
}

// GetLatestVersionCheckFile grabs the check file used to determine when to run the version check.
Expand All @@ -236,7 +236,7 @@ func GetLatestVersionCheckFile(logger *slog.Logger) (string, error) {
}

epoch := time.Unix(0, 0)
if err := os.WriteFile(lastCheckFile, []byte(epoch.Format(time.RFC3339)), 0644); err != nil {
if err := os.WriteFile(lastCheckFile, []byte(epoch.Format(time.RFC3339)), 0666); err != nil {
logger.Error("Error writing last check file", "err", err)
return "", err
}
Expand Down

0 comments on commit db2581e

Please sign in to comment.