diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-07-03 13:51:37 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-07-03 13:51:37 -0700 |
| commit | 8a1512f9d2c16c8d811099fbb3a168cc2d7ec074 (patch) | |
| tree | 46702fd67b7c5c72ff3332889879fdd7c864a8c6 /hotline/transaction_handlers.go | |
| parent | 969e6481f12ed859e42ed81699547d2d33b0637f (diff) | |
Fix filepath handling and backfill test
Diffstat (limited to 'hotline/transaction_handlers.go')
| -rw-r--r-- | hotline/transaction_handlers.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/hotline/transaction_handlers.go b/hotline/transaction_handlers.go index 4866bee..3ecb6bd 100644 --- a/hotline/transaction_handlers.go +++ b/hotline/transaction_handlers.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "gopkg.in/yaml.v3" - "io/ioutil" "math/big" "os" "path" @@ -1001,14 +1000,14 @@ func HandleTranOldPostNews(cc *ClientConn, t *Transaction) (res []Transaction, e newsPost := fmt.Sprintf(newsTemplate+"\r", cc.UserName, time.Now().Format(newsDateTemplate), t.GetField(fieldData).Data) newsPost = strings.Replace(newsPost, "\n", "\r", -1) - // update news in memory - cc.Server.FlatNews = append([]byte(newsPost), cc.Server.FlatNews...) - // update news on disk - if err := ioutil.WriteFile(cc.Server.ConfigDir+"MessageBoard.txt", cc.Server.FlatNews, 0644); err != nil { + if err := cc.Server.FS.WriteFile(filepath.Join(cc.Server.ConfigDir, "MessageBoard.txt"), cc.Server.FlatNews, 0644); err != nil { return res, err } + // update news in memory + cc.Server.FlatNews = append([]byte(newsPost), cc.Server.FlatNews...) + // Notify all clients of updated news cc.sendAll( tranNewMsg, |