Fix and add error messages to fs operations
This commit is contained in:
parent
d8f4fd8aa5
commit
9108dbd40b
10
socket.go
10
socket.go
@ -459,7 +459,7 @@ func handleConnection(conn net.Conn, dev *infinitime.Device, fs *blefs.FS) {
|
|||||||
}
|
}
|
||||||
// If no data, return error
|
// If no data, return error
|
||||||
if req.Data == nil {
|
if req.Data == nil {
|
||||||
connErr(conn, req.Type, nil, "Data required for firmware upgrade request")
|
connErr(conn, req.Type, nil, "Data required for filesystem operations")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
var reqData types.ReqDataFS
|
var reqData types.ReqDataFS
|
||||||
@ -471,6 +471,10 @@ func handleConnection(conn net.Conn, dev *infinitime.Device, fs *blefs.FS) {
|
|||||||
}
|
}
|
||||||
switch reqData.Type {
|
switch reqData.Type {
|
||||||
case types.FSTypeDelete:
|
case types.FSTypeDelete:
|
||||||
|
if len(reqData.Files) == 0 {
|
||||||
|
connErr(conn, req.Type, nil, "Remove FS command requires at least one file")
|
||||||
|
break
|
||||||
|
}
|
||||||
for _, file := range reqData.Files {
|
for _, file := range reqData.Files {
|
||||||
err := fs.Remove(file)
|
err := fs.Remove(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -491,6 +495,10 @@ func handleConnection(conn net.Conn, dev *infinitime.Device, fs *blefs.FS) {
|
|||||||
}
|
}
|
||||||
json.NewEncoder(conn).Encode(types.Response{Type: req.Type})
|
json.NewEncoder(conn).Encode(types.Response{Type: req.Type})
|
||||||
case types.FSTypeMkdir:
|
case types.FSTypeMkdir:
|
||||||
|
if len(reqData.Files) == 0 {
|
||||||
|
connErr(conn, req.Type, nil, "Mkdir FS command requires at least one file")
|
||||||
|
break
|
||||||
|
}
|
||||||
for _, file := range reqData.Files {
|
for _, file := range reqData.Files {
|
||||||
err := fs.Mkdir(file)
|
err := fs.Mkdir(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user