forked from tidwall/tile38
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadonly.go
More file actions
40 lines (37 loc) · 689 Bytes
/
Copy pathreadonly.go
File metadata and controls
40 lines (37 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package controller
import (
"strings"
"github.com/tidwall/tile38/log"
)
func (c *Controller) cmdReadOnly(line string) error {
var arg string
if line, arg = token(line); arg == "" {
return errInvalidNumberOfArguments
}
if line != "" {
return errInvalidNumberOfArguments
}
backup := c.config
switch strings.ToLower(arg) {
default:
return errInvalidArgument(arg)
case "yes":
if c.config.ReadOnly {
return nil
}
c.config.ReadOnly = true
log.Info("read only")
case "no":
if !c.config.ReadOnly {
return nil
}
c.config.ReadOnly = false
log.Info("read write")
}
err := c.writeConfig()
if err != nil {
c.config = backup
return err
}
return nil
}