// Restore is used to efficiently manage restoring a large amount of data into
// the state store. It works by doing all the restores inside of a single
// transaction.
496973
func (s *Store) Restore() *Restore {
	tx := s.db.Txn(true)
	return &Restore{s, tx}
}
408815
func (p *Plot) Restore() *Plot {
	if p.env.parent == nil {
		panic("unbalanced Save/Restore")
	}
	p.env = p.env.parent
	return p
}
36834
func (s *Storage) Reset() {
	s.setBoltDB(storage.TotalCountKey, 0)
	s.setBoltDB(storage.IosSuccessKey, 0)
	s.setBoltDB(storage.IosErrorKey, 0)
	s.setBoltDB(storage.AndroidSuccessKey, 0)
	s.setBoltDB(storage.AndroidErrorKey, 0)
}
242737
func (a *Agent) restoreCheckState(snap map[types.CheckID]*structs.HealthCheck) {
	for id, check := range snap {
		a.State.UpdateCheck(id, check.Status, check.Output)
	}
}
1172347
func (t *Term) Restore() error {
	return termios.Tcsetattr(uintptr(t.fd), termios.TCIOFLUSH, &t.orig)
}
921589
func (d *digest) Restore(state []byte) error {
	decoder := gob.NewDecoder(bytes.NewReader(state))

	// We decode this way so that we do not have
	// to export these fields of the digest struct.
	vals := []interface{}{
		&d.h, &d.x, &d.nx, &d.len, &d.is224,
	}

	for _, val := range vals {
		if err := decoder.Decode(val); err != nil {
			return err
		}
	}

	return nil
}
989840
func (s *MemoryStore) Restore(snapshot *pb.StoreSnapshot) error {
	return s.updateLocal(func(tx Tx) error {
		for _, os := range objectStorers {
			if err := os.Restore(tx, snapshot); err != nil {
				return err
			}
		}
		return nil
	})
}
1188889
func (p *parser) restore(pt savepoint) {
	if pt.offset == p.pt.offset {
		return
	}
	p.pt = pt
}
78472
func (p *Process) Restore(r io.Reader) (*BackupInfo, error) {
	if err := p.writeConfig(configData{}); err != nil {
		return nil, err
	}
	if err := p.unpackXbstream(r); err != nil {
		return nil, err
	}
	backupInfo, err := p.extractBackupInfo()
	if err != nil {
		return nil, err
	}
	if err := p.restoreApplyLog(); err != nil {
		return nil, err
	}
	return backupInfo, nil
}
1069156
func (f *flotillaState) Restore(in io.ReadCloser) error {
	// stream to filePath.tmp
	tempData := f.tempPath + "/data.mdb"
	_ = os.Remove(tempData)
	tempFile, err := os.Create(tempData)
	if err != nil {
		return err
	}
	defer tempFile.Close()
	if _, err = io.Copy(tempFile, in); err != nil {
		return err
	}
	// unlink existing DB and move new one into place
	// can't atomically rename directories so have to lock for this
	f.l.Lock()
	defer f.l.Unlock()
	if err = syscall.Unlink(f.dataPath + "/data.mdb"); err != nil {
		return err
	}
	if err = syscall.Unlink(f.dataPath + "/lock.mdb"); err != nil {
		return err
	}
	if err = os.Rename(tempData, f.dataPath+"/data.mdb"); err != nil {
		return err
	}
	// mark existing env as closeable when all outstanding txns finish
	// posix holds onto our data until we release FD
	f.env.Close()
	// re-initialize env
	f.env, err = newenv(f.dataPath)
	return err
}
1080674
func (context *OpsManager) Restore() (err error) {
	lo.G.Info("Starting restore for Opsman")
	err = context.importInstallation()
	return
}
839332
func restore(store string) {
	files, rderr := ioutil.ReadDir(store)
	chkerr(rderr)
	for _, f := range files {
		fname := f.Name()
		if len(fname) > 4 {
			if fname[len(fname)-4:] == bkpExt {
				key := fname[0 : len(fname)-4]
				fulp := fullpath(store, key)
				msg, cerr := os.Create(fulp)
				chkerr(cerr)
				bkpp := path.Join(store, fname)
				bkp, oerr := os.Open(bkpp)
				chkerr(oerr)
				n, cerr := io.Copy(msg, bkp)
				chkerr(cerr)
				chkcond(n > 0)
				clmerr := msg.Close()
				chkerr(clmerr)
				clberr := bkp.Close()
				chkerr(clberr)
				remerr := os.Remove(bkpp)
				chkerr(remerr)
			}
		}
	}
}
235614
func (s *Snapshot) Restore(q *WriteOptions, in io.Reader) error {
	r := s.c.newRequest("PUT", "/v1/snapshot")
	r.body = in
	r.setWriteOptions(q)
	_, _, err := requireOK(s.c.doRequest(r))
	if err != nil {
		return err
	}
	return nil
}
1262573
func (c *Connection) Restore(dbConn *sdb.Conn, s *Store) {
	c.dbMu.Lock()
	defer c.dbMu.Unlock()
	c.db = dbConn
	c.store = s
	c.logger = log.New(os.Stderr, connectionLogPrefix(c.ID), log.LstdFlags)
}
864724
func (kvm *Clone) Restore(rd io.Reader) error {
	kvm.mu.Lock()
	defer kvm.mu.Unlock()
	data, err := ioutil.ReadAll(rd)
	if err != nil {
		return err
	}
	var keys map[string][]byte
	if err := json.Unmarshal(data, &keys); err != nil {
		return err
	}
	kvm.keys = keys
	return nil
}
816489
func (dao *ControlPlaneDao) Restore(restoreRequest model.RestoreRequest, _ *int) (err error) {
	ctx := datastore.Get()
	if len(restoreRequest.Username) > 0 {
		ctx.SetUser(restoreRequest.Username)
	}
	dfslocker := dao.facade.DFSLock(ctx)
	dfslocker.Lock("restore")
	defer dfslocker.Unlock()
	inprogress.SetProgress(restoreRequest.Filename, "restore")
	defer func() {
		if err != nil {
			log.WithError(err).Error("Restore failed with error")
		}
		inprogress.SetError(err)
	}()
	info, err := dfs.ExtractBackupInfo(restoreRequest.Filename)
	if err != nil {
		return err
	}
	fh, err := os.Open(restoreRequest.Filename)
	if err != nil {
		return err
	}
	defer fh.Close()
	gz, err := gzip.NewReader(fh)
	if err != nil {
		return err
	}
	defer gz.Close()
	err = dao.facade.Restore(ctx, gz, info, restoreRequest.Filename)
	return err
}
1263729
func (s *Storage) Reset() {
	setLevelDB(storage.TotalCountKey, 0)
	setLevelDB(storage.IosSuccessKey, 0)
	setLevelDB(storage.IosErrorKey, 0)
	setLevelDB(storage.AndroidSuccessKey, 0)
	setLevelDB(storage.AndroidErrorKey, 0)
}