Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/ssl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"os"
"time"

MQTT "github.com/eclipse/paho.mqtt.golang"
Expand All @@ -59,7 +59,7 @@ func NewTLSConfig() *tls.Config {
// Alternatively, manually add CA certificates to
// default openssl CA bundle.
certpool := x509.NewCertPool()
pemCerts, err := ioutil.ReadFile("samplecerts/CAfile.pem")
pemCerts, err := os.ReadFile("samplecerts/CAfile.pem")
if err == nil {
certpool.AppendCertsFromPEM(pemCerts)
}
Expand Down
16 changes: 12 additions & 4 deletions filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package mqtt

import (
"io/ioutil"
"os"
"path"
"sort"
Expand Down Expand Up @@ -159,14 +158,23 @@ func (store *FileStore) Reset() {
func (store *FileStore) all() []string {
var err error
var keys []string
var files fileInfos

if !store.opened {
ERROR.Println(STR, "trying to use file store, but not open")
return nil
}

files, err = ioutil.ReadDir(store.directory)
entries, err := os.ReadDir(store.directory)
if err != nil {
return nil
}
files := make(fileInfos, 0, len(entries))
for _, entry := range entries {
info, err := entry.Info()
if err != nil {
return nil
}
files = append(files, info)
}
chkerr(err)
sort.Sort(files)
for _, f := range files {
Expand Down
3 changes: 1 addition & 2 deletions fvt_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package mqtt

import (
"bytes"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -250,7 +249,7 @@ func Test_FileStore_Get_Corrupted(t *testing.T) {
t.Fatalf("corrupt message not archived")
}

contents, err := ioutil.ReadFile(storedir + "/o.120.CORRUPT")
contents, err := os.ReadFile(storedir + "/o.120.CORRUPT")
chkerr(err)

if !bytes.Equal(exp, contents) {
Expand Down