func saveCsrfTokens() { // We're ignoring errors in here. It's not super critical and there's // nothing relevant we can do about them anyway... name := locations[locCsrfTokens] f, err := osutil.CreateAtomic(name, 0600) if err != nil { return } for _, t := range csrfTokens { fmt.Fprintln(f, t) } f.Close() }
// Save writes the configuration to disk, and generates a ConfigSaved event. func (w *Wrapper) Save() error { fd, err := osutil.CreateAtomic(w.path, 0600) if err != nil { return err } if err := w.cfg.WriteXML(fd); err != nil { fd.Close() return err } if err := fd.Close(); err != nil { return err } events.Default.Log(events.ConfigSaved, w.cfg) return nil }
func (m *Model) SetIgnores(folder string, content []string) error { cfg, ok := m.folderCfgs[folder] if !ok { return fmt.Errorf("Folder %s does not exist", folder) } fd, err := osutil.CreateAtomic(filepath.Join(cfg.Path(), ".stignore"), 0644) if err != nil { l.Warnln("Saving .stignore:", err) return err } for _, line := range content { fmt.Fprintln(fd, line) } if err := fd.Close(); err != nil { l.Warnln("Saving .stignore:", err) return err } return m.ScanFolder(folder) }