// UpdateMeta updates meta table
181824
func UpdateMeta(driver db.DB, metas []models.FeedMeta) error {
	for _, meta := range metas {
		meta.Hash = meta.LatestHash
		meta.LastModifiedDate = meta.LatestLastModifiedDate
		err := driver.UpsertFeedHash(meta)
		if err != nil {
			return fmt.Errorf("Failed to updte meta: %s, err: %s",
				meta.URL, err)
		}
	}
	return nil
}
631647
func (sp *SignedSnapshot) AddMeta(role RoleName, meta FileMeta) {
	sp.Signed.Meta[role.String()] = meta
	sp.Dirty = true
}
1073659
func (st *MemStorage) UpdateMany(gun data.GUN, updates []MetaUpdate) error {
	st.lock.Lock()
	defer st.lock.Unlock()

	versioner := make(map[string]map[int]struct{})
	constant := struct{}{}

	// ensure that we only update in one transaction
	for _, u := range updates {
		id := entryKey(gun, u.Role)

		// prevent duplicate versions of the same role
		if _, ok := versioner[u.Role.String()][u.Version]; ok {
			return ErrOldVersion{}
		}
		if _, ok := versioner[u.Role.String()]; !ok {
			versioner[u.Role.String()] = make(map[int]struct{})
		}
		versioner[u.Role.String()][u.Version] = constant

		if space, ok := st.tufMeta[id]; ok {
			for _, v := range space {
				if v.version >= u.Version {
					return ErrOldVersion{}
				}
			}
		}
	}

	for _, u := range updates {
		id := entryKey(gun, u.Role)

		version := ver{version: u.Version, data: u.Data, createupdate: time.Now()}
		st.tufMeta[id] = append(st.tufMeta[id], version)
		sort.Sort(st.tufMeta[id]) // ensure that it's sorted
		checksumBytes := sha256.Sum256(u.Data)
		checksum := hex.EncodeToString(checksumBytes[:])

		_, ok := st.checksums[gun.String()]
		if !ok {
			st.checksums[gun.String()] = make(map[string]ver)
		}
		st.checksums[gun.String()][checksum] = version
		if u.Role == data.CanonicalTimestampRole {
			st.writeChange(gun, u.Version, checksum)
		}
	}
	return nil
}
671868
func (db *schemaUpdater) updateSchemaTo5() {
	t := db.newReadWriteTransaction()
	var nk []byte
	for _, folderStr := range db.ListFolders() {
		nk = db.keyer.GenerateNeedFileKey(nk, []byte(folderStr), nil)
		t.deleteKeyPrefix(nk[:keyPrefixLen+keyFolderLen])
	}
	t.close()

	db.updateSchema2to3()
}
1270911
func (t *Task) SetMeta(key, val string) *Task {
	if t.Meta == nil {
		t.Meta = make(map[string]string)
	}
	t.Meta[key] = val
	return t
}
498133
func (db *instance) updateRemoteFiles(folder, device []byte, fs []protocol.FileInfo, meta *metadataTracker) {
	t := db.newReadWriteTransaction()
	defer t.close()

	var dk, gk, keyBuf []byte
	devID := protocol.DeviceIDFromBytes(device)
	for _, f := range fs {
		name := []byte(f.Name)
		dk = db.keyer.GenerateDeviceFileKey(dk, folder, device, name)

		ef, ok := t.getFileTrunc(dk, true)
		if ok && unchanged(f, ef) {
			continue
		}

		if ok {
			meta.removeFile(devID, ef)
		}
		meta.addFile(devID, f)

		l.Debugf("insert; folder=%q device=%v %v", folder, devID, f)
		t.Put(dk, mustMarshal(&f))

		gk = db.keyer.GenerateGlobalVersionKey(gk, folder, name)
		keyBuf, _ = t.updateGlobal(gk, keyBuf, folder, device, f, meta)

		t.checkFlush()
	}
}
420535
func (s *StartRestoreJobInput) SetMetadata(v map[string]*string) *StartRestoreJobInput {
	s.Metadata = v
	return s
}
622357
func (tx *Tx) writeMeta() error {
	// Create a temporary buffer for the meta page.
	buf := make([]byte, tx.db.pageSize)
	p := tx.db.pageInBuffer(buf, 0)
	tx.meta.write(p)

	// Write the meta page to file.
	if _, err := tx.db.ops.writeAt(buf, int64(p.id)*int64(tx.db.pageSize)); err != nil {
		return err
	}
	if !tx.db.NoSync || IgnoreNoSync {
		if err := fdatasync(tx.db); err != nil {
			return err
		}
	}

	// Update statistics.
	tx.stats.Write++

	return nil
}
1278029
func (gce *Connection) UpdateMetadata(key, value string, ids ...string) error {
	if len(ids) == 0 {
		return nil
	}

	instances, err := gce.raw.ListInstances(gce.projectID, "")
	if err != nil {
		return errors.Annotatef(err, "updating metadata for instances %v", ids)
	}
	var failed []string
	for _, instID := range ids {
		for _, inst := range instances {
			if inst.Name == instID {
				if err := gce.updateInstanceMetadata(inst, key, value); err != nil {
					failed = append(failed, instID)
					logger.Errorf("while updating metadata for instance %q (%v=%q): %v",
						instID, key, value, err)
				}
				break
			}
		}
	}
	if len(failed) != 0 {
		return errors.Errorf("some metadata updates failed: %v", failed)
	}
	return nil

}
1021347
func (s *GetDocumentVersionOutput) SetMetadata(v *DocumentVersionMetadata) *GetDocumentVersionOutput {
	s.Metadata = v
	return s
}
392484
func (s *GetPipelineOutput) SetMetadata(v *PipelineMetadata) *GetPipelineOutput {
	s.Metadata = v
	return s
}
698613
func (em *EventManager) NewEventMeta(meta EventMeta) (EventSubs, bool) {
	if meta.Removed() {
		return nil, false
	}

	eo := BuildEventID(meta.Type(), meta.Target())

	if em.HasEvent(eo) {
		ed, _ := em.GetEvent(eo)
		return ed, false
	}

	emo := MetaEventSub(meta)

	em.AddEvent(emo)
	return emo, true
}
331092
func (a *ExtendedStatsAggregation) Meta(metaData map[string]interface{}) *ExtendedStatsAggregation {
	a.meta = metaData
	return a
}
1152631
func (s *Store) SetMetadata(md map[string]string) error {
	return s.setMetadata(s.raftID, md)
}
709818
func (db *DB) checkMeta() (bool, error) {
	var version []byte
	err := db.db.Update(func(tx *bolt.Tx) error {
		meta, err := tx.CreateBucketIfNotExists([]byte("meta"))
		if err != nil {
			return err
		}

		version = meta.Get([]byte("version"))
		if version != nil {
			return nil
		}

		err = meta.Put([]byte("version"), schemaVersion)
		if err != nil {
			return err
		}
		version = schemaVersion
		return nil
	})

	return bytes.Equal(version, schemaVersion), err
}
259253
func (a *Agent) updateToken(target, token string, q *WriteOptions) (*WriteMeta, error) {
	meta, _, err := a.updateTokenOnce(target, token, q)
	return meta, err
}
303678
func (p *Params) AddMetadata(key, value string) {
	if p.Metadata == nil {
		p.Metadata = make(map[string]string)
	}

	p.Metadata[key] = value
}