Add proxying memfs files

This commit is contained in:
Ingo Oppermann
2022-08-04 16:43:19 +02:00
parent fe889aa4e2
commit c31fd657be
7 changed files with 177 additions and 22 deletions

View File

@@ -15,9 +15,10 @@ type NodeReader interface {
}
type NodeState struct {
ID string
State string
Files []string
ID string
State string
Files []string
LastUpdate time.Time
}
type nodeState string
@@ -110,7 +111,8 @@ func (n *node) State() NodeState {
defer n.lock.RUnlock()
state := NodeState{
ID: n.peer.ID(),
ID: n.peer.ID(),
LastUpdate: n.lastUpdate,
}
if n.state == stateDisconnected || time.Since(n.lastUpdate) > 2*time.Second {
@@ -131,6 +133,8 @@ func (n *node) stop() {
func (n *node) files() {
files, err := n.peer.MemFSList("name", "asc")
n.lastUpdate = time.Now()
if err != nil {
n.fileList = nil
n.state = stateDisconnected
@@ -145,7 +149,5 @@ func (n *node) files() {
n.fileList[i] = file.Name
}
n.lastUpdate = time.Now()
return
}