Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 6774697

Browse files
committed
Add stuff
1 parent 1958657 commit 6774697

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func LoadConfig() {
3333
if _, err := os.Stat(homePath + "/.config/rssnix/config.ini"); errors.Is(err, os.ErrNotExist) {
3434
log.Warn("Config file does not exist, creating...")
3535

36-
os.MkdirAll(homePath+"/.config/rssnix", 0644)
36+
os.MkdirAll(homePath+"/.config/rssnix", 0777)
3737
file, err := os.Create(homePath + "/.config/rssnix/config.ini")
3838
if err != nil {
3939
log.Error("Failed to create a config file")
@@ -57,7 +57,7 @@ func LoadConfig() {
5757
if strings.HasPrefix(Config.FeedDirectory, "~") {
5858
Config.FeedDirectory = homePath + Config.FeedDirectory[1:]
5959
}
60-
os.MkdirAll(Config.FeedDirectory, 0644)
60+
os.MkdirAll(Config.FeedDirectory, 0777)
6161
Config.Viewer = cfg.Section("settings").Key("viewer").String()
6262
for _, key := range cfg.Section("feeds").Keys() {
6363
Config.Feeds = append(Config.Feeds, Feed{key.Name(), key.String()})

feed.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"os"
55
"strconv"
6+
"strings"
67
"sync"
78

89
"github.com/mmcdole/gofeed"
@@ -20,7 +21,7 @@ var isAllUpdate bool
2021

2122
func DeleteFeedFiles(name string) {
2223
os.RemoveAll(Config.FeedDirectory + "/" + name)
23-
os.Mkdir(Config.FeedDirectory+"/"+name, 0644)
24+
os.MkdirAll(Config.FeedDirectory+"/"+name, 0777)
2425
}
2526

2627
func UpdateFeed(name string) {
@@ -29,7 +30,7 @@ func UpdateFeed(name string) {
2930
feed, _ := fp.ParseURL(Config.Feeds[slices.IndexFunc(Config.Feeds, func(f Feed) bool { return f.Name == name })].URL)
3031
DeleteFeedFiles(name)
3132
for _, item := range feed.Items {
32-
file, err := os.Create(Config.FeedDirectory + "/" + name + "/" + item.Title)
33+
file, err := os.Create(Config.FeedDirectory + "/" + name + "/" + strings.ReplaceAll(item.Title, "/", ""))
3334
if err != nil {
3435
log.Error("Failed to create a file for article titled '" + item.Title + "'")
3536
continue

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import (
44
"errors"
55
"os"
66
"os/exec"
7+
"syscall"
78

89
log "github.com/sirupsen/logrus"
910
"github.com/urfave/cli/v2"
1011
)
1112

1213
func main() {
14+
syscall.Umask(0)
1315
LoadConfig()
1416

1517
app := &cli.App{
@@ -78,7 +80,7 @@ func main() {
7880
log.Error("Failed to get home path")
7981
os.Exit(1)
8082
}
81-
file, err := os.OpenFile(homePath+"/.config/rssnix/config.ini", os.O_APPEND|os.O_WRONLY, 644)
83+
file, err := os.OpenFile(homePath+"/.config/rssnix/config.ini", os.O_APPEND|os.O_WRONLY, 0644)
8284
if err != nil {
8385
return err
8486
}

0 commit comments

Comments
 (0)