Skip to content

Commit

Permalink
feed config is written in tabbed json
Browse files Browse the repository at this point in the history
  • Loading branch information
ybizeul committed Sep 17, 2024
1 parent ee19aad commit 0e4bb28
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/feed/feedConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,17 @@ func FeedConfigForFeed(f *Feed) (*FeedConfig, error) {
}

func (config *FeedConfig) Write() error {
b, err := json.Marshal(config)
configPath := path.Join(config.feed.Path, "config.json")

f, err := os.Create(configPath)
if err != nil {
return err
return fmt.Errorf("%w: %s", FeedConfigErrorCantWrite, configPath)
}

configPath := path.Join(config.feed.Path, "config.json")
err = os.WriteFile(configPath, b, 0600)
e := json.NewEncoder(f)
e.SetIndent("", " ")
err = e.Encode(config)

if err != nil {
return fmt.Errorf("%w: %s", FeedConfigErrorCantWrite, configPath)
}
Expand Down

0 comments on commit 0e4bb28

Please sign in to comment.