mirror of
https://github.com/pgsty/minio.git
synced 2026-08-10 16:23:28 +03:00
Persist offline mqtt events in the queueDir and replay (#7037)
This commit is contained in:
committed by
Harshavardhana
parent
8757c963ba
commit
6571641735
+23
-3
@@ -18,6 +18,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"github.com/eclipse/paho.mqtt.golang/packets"
|
||||
@@ -150,13 +151,18 @@ func (store *FileStore) Reset() {
|
||||
|
||||
// lockless
|
||||
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
|
||||
}
|
||||
keys := []string{}
|
||||
files, rderr := ioutil.ReadDir(store.directory)
|
||||
chkerr(rderr)
|
||||
|
||||
files, err = ioutil.ReadDir(store.directory)
|
||||
chkerr(err)
|
||||
sort.Sort(files)
|
||||
for _, f := range files {
|
||||
DEBUG.Println(STR, "file in All():", f.Name())
|
||||
name := f.Name()
|
||||
@@ -233,3 +239,17 @@ func exists(file string) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type fileInfos []os.FileInfo
|
||||
|
||||
func (f fileInfos) Len() int {
|
||||
return len(f)
|
||||
}
|
||||
|
||||
func (f fileInfos) Swap(i, j int) {
|
||||
f[i], f[j] = f[j], f[i]
|
||||
}
|
||||
|
||||
func (f fileInfos) Less(i, j int) bool {
|
||||
return f[i].ModTime().Before(f[j].ModTime())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user