MCPcopy Index your code
hub / github.com/Monibuca/engine / Save

Method Save

plugin.go:168–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

166}
167
168func (opt *Plugin) Save() error {
169 if opt.saveTimer == nil {
170 var lock sync.Mutex
171 opt.saveTimer = time.AfterFunc(time.Second, func() {
172 lock.Lock()
173 defer lock.Unlock()
174 if opt.RawConfig.Modify == nil {
175 os.Remove(opt.settingPath())
176 return
177 }
178 file, err := os.OpenFile(opt.settingPath(), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)
179 if err == nil {
180 defer file.Close()
181 err = yaml.NewEncoder(file).Encode(opt.RawConfig.Modify)
182 }
183 if err == nil {
184 opt.Info("config saved")
185 }
186 })
187 } else {
188 opt.saveTimer.Reset(time.Second)
189 }
190 return nil
191}
192
193func (opt *Plugin) AssignPubConfig(puber *Publisher) {
194 if puber.Config == nil {

Callers 4

API_modifyConfigMethod · 0.95
API_updateConfigMethod · 0.95
PullMethod · 0.95
PushMethod · 0.95

Calls 6

settingPathMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80
CloseMethod · 0.65
InfoMethod · 0.65
ResetMethod · 0.65

Tested by

no test coverage detected