only add to watchlist if open is successful
This commit is contained in:
parent
84a647d6d1
commit
05fd80d4c5
1 changed files with 6 additions and 3 deletions
|
|
@ -648,12 +648,15 @@ func wsHeartbeat(ctx context.Context, c *websocket.Conn) {
|
|||
}
|
||||
}
|
||||
|
||||
// trackedFS is OS's FS with the addition that it tracks which files are opened
|
||||
// trackedFS is OS's FS with the addition that it tracks which files are opened successfully
|
||||
type trackedFS struct {
|
||||
opened []string
|
||||
}
|
||||
|
||||
func (tfs *trackedFS) Open(name string) (fs.File, error) {
|
||||
tfs.opened = append(tfs.opened, name)
|
||||
return os.Open(name)
|
||||
f, err := os.Open(name)
|
||||
if err == nil {
|
||||
tfs.opened = append(tfs.opened, name)
|
||||
}
|
||||
return f, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue