// Save stores a secret for a specific username.
193525
func (pwm *Manager) Save(username, secret string) error {
	//TODO: username and secret validation

	storedSecret := userSecret{Username: username, Secret: secret}

	_, err := pwm.collection.Upsert(bson.M{"username": username}, storedSecret)

	return err
}
925619
func (s *sessionV8) save() *probe.Error {
	sessionFile, err := getSessionFile(s.SessionID)
	if err != nil {
		return err.Trace(s.SessionID)
	}

	// Verify if sessionFile is modified.
	modified, err := s.isModified(sessionFile)
	if err != nil {
		return err.Trace(s.SessionID)
	}
	// Header is modified, we save it.
	if modified {
		qs, e := quick.NewConfig(s.Header, nil)
		if e != nil {
			return probe.NewError(e).Trace(s.SessionID)
		}
		// Save an return.
		e = qs.Save(sessionFile)
		if e != nil {
			return probe.NewError(e).Trace(sessionFile)
		}
	}
	return nil
}
447411
func (store DataStore) Save(key string, item interface{}) error {
	encodedItem, err := store.Encoding.Encode(item)
	if err != nil {
		return err
	}
	return SetItem(key, string(encodedItem))
}
330864
func Save(r *http.Request, w http.ResponseWriter) error {
	return GetRegistry(r).Save(w)
}
496223
func (s shareDBV1) Save(filename string) *probe.Error {
	s.mutex.Lock()
	defer s.mutex.Unlock()

	return s.save(filename)
}
790513
func (f *File) Save(filename string) error {
	// notest
	buf := &bytes.Buffer{}
	if err := f.Render(buf); err != nil {
		return err
	}
	if err := ioutil.WriteFile(filename, buf.Bytes(), 0644); err != nil {
		return err
	}
	return nil
}
528797
func (r *Redis) Save(k models.Key, m models.Model) error {
	b, err := m.MarshalBinary()
	if err != nil {
		return err
	}
	return r.client.Set(k.String(), b, time.Duration(0)).Err()
}
127564
func (c *ConfigFile) Save() error {
	rw, err := NewConfigReadWriter(c.version)
	if err != nil {
		return err
	}
	filename := rw.Filename(c)
	if filename == "" {
		return fmt.Errorf("Can't save config with empty filename")
	}
	if err := os.MkdirAll(filepath.Dir(filename), 0700); err != nil {
		return err
	}
	file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
	if err != nil {
		return err
	}
	defer file.Close()
	return rw.SaveToWriter(file, c)
}
338129
func (s shareDBV1) save(filename string) *probe.Error {
	// Initialize a new quick file.
	qs, e := quick.NewConfig(s, nil)
	if e != nil {
		return probe.NewError(e).Trace(filename)
	}
	if e := qs.Save(filename); e != nil {
		return probe.NewError(e).Trace(filename)
	}
	return nil
}
629950
func (d *DirPreferences) Save() error {
	f, err := os.Create(d.Path)
	if err != nil {
		return err
	}

	defer f.Close()

	enc := json.NewEncoder(f)
	return enc.Encode(d)
}
766606
func (m *Manager) Save(w http.ResponseWriter, s *Session) error {
	m.setCookie(w, s)

	opt := makeStoreOption(m, s)

	// detect is flash changed and encode new flash data
	if s.flash != nil && s.flash.Changed() {
		b, _ := s.flash.encode()
		s.Set(flashKey, b)
	}

	// if session not modified, don't save to store to prevent store overflow
	if !m.config.Resave && !s.Changed() {
		return nil
	}

	// save sesion data to store
	s.Set(timestampKey, time.Now().Unix())
	return m.config.Store.Set(s.id, s.data, opt)
}
1278845
func (cm *ClosestMatch) Save(filename string) error {
	f, err := os.Create(filename)
	if err != nil {
		return err
	}
	defer f.Close()
	w := gzip.NewWriter(f)
	defer w.Close()
	enc := json.NewEncoder(w)
	// enc.SetIndent("", " ")
	return enc.Encode(cm)
}
771327
func (k *Store) Save() error {
	k.mu.Lock()
	defer k.mu.Unlock()

	// Short-circuit if we have no changes
	if len(k.log) == 0 {
		return nil
	}

	// firstly peek at version; open read/write to keep lock between check & write
	f, err := os.OpenFile(k.filename, os.O_RDWR|os.O_CREATE, 0664)
	if err != nil {
		return err
	}

	defer f.Close()

	// Only try to merge if > 0 bytes, ignore empty files (decoder will fail)
	if stat, _ := f.Stat(); stat.Size() > 0 {
		k.loadAndMergeReaderIfNeeded(f)
		// Now we overwrite the file
		f.Seek(0, os.SEEK_SET)
		f.Truncate(0)
	}

	k.version++

	enc := gob.NewEncoder(f)
	if err := enc.Encode(k.version); err != nil {
		return fmt.Errorf("Error while writing version data to %v: %v", k.filename, err)
	}
	if err := enc.Encode(k.db); err != nil {
		return fmt.Errorf("Error while writing new key/value data to %v: %v", k.filename, err)
	}
	// Clear log now that it's saved
	k.log = nil

	return nil
}
942826
func (c Config) Save() error {
	bs, err := json.MarshalIndent(c, "", "    ")
	if err != nil {
		log.Debug(err)
		return errors.New("unable to save config file")
	}

	configPath := filepath.Join(ConfigDir(), ConfigFileName)

	fi, err := os.Stat(configPath)
	if err != nil {
		log.Debug(err)
		return errors.New("unable to save config file")
	}

	if err = ioutil.WriteFile(configPath, bs, fi.Mode()); err != nil {
		log.Debug(err)
		return errors.New("unable to save config file")
	}

	return nil
}
85065
func Save(filename string, img image.Image, encoder Encoder) error {
	// filename = strings.TrimSuffix(filename, filepath.Ext(filename))
	f, err := os.Create(filename)
	if err != nil {
		return err
	}
	defer f.Close()
	return encoder(f, img)
}
1312776
func (cfg *Config) save(storage util.Storage) {
	storage.Set("uuid", []byte(cfg.id))
	storage.Set("version", []byte(fmt.Sprintf("%d", cfg.version)))
	storage.Set("configHash", []byte(cfg.configHash))
}
634821
func (s *Store) Save(i interface{}) error {
	location := s.Path(i)

	b, err := yaml.Marshal(i)
	if err != nil {
		return err
	}

	return ioutil.WriteFile(location, b, 0644)
}