OpenUserCheck checks if the current user dict file has been modified since last open time and re-opens it if so.
()
| 86 | // OpenUserCheck checks if the current user dict file has been modified |
| 87 | // since last open time and re-opens it if so. |
| 88 | func (sp *SpellData) OpenUserCheck() error { |
| 89 | if sp.UserFile == "" { |
| 90 | return nil |
| 91 | } |
| 92 | sp.mu.Lock() |
| 93 | defer sp.mu.Unlock() |
| 94 | tm, err := modTime(sp.UserFile) |
| 95 | if err != nil { |
| 96 | return err |
| 97 | } |
| 98 | if tm.After(sp.openTime) { |
| 99 | sp.OpenUser() |
| 100 | sp.openTime = tm |
| 101 | // log.Printf("opened newer spell file: %s\n", openTime.String()) |
| 102 | } |
| 103 | return err |
| 104 | } |
| 105 | |
| 106 | // SaveUser saves the user dictionary |
| 107 | // note: this will overwrite any existing file; be sure to have opened |
no test coverage detected