Ensure that the FS works after a reconnect

This commit is contained in:
2021-11-25 20:35:03 -08:00
parent b363a20a9d
commit 655af5c446
4 changed files with 24 additions and 4 deletions

View File

@@ -107,6 +107,20 @@ func startSocket(dev *infinitime.Device) error {
func handleConnection(conn net.Conn, dev *infinitime.Device, fs *blefs.FS) {
defer conn.Close()
// If an FS update is required (reconnect ocurred)
if updateFS {
// Get new FS
newFS, err := dev.FS()
if err != nil {
fs = nil
log.Warn().Err(err).Msg("Error updating BLE filesystem")
}
// Set FS pointer to new FS
*fs = *newFS
// Reset updateFS
updateFS = false
}
// Create new scanner on connection
scanner := bufio.NewScanner(conn)
for scanner.Scan() {