// Archive stores the
11538
func (s *WMailServer) Archive(env *whisper.Envelope) {
	key := NewDbKey(env.Expiry-env.TTL, env.Hash())
	rawEnvelope, err := rlp.EncodeToBytes(env)
	if err != nil {
		log.Error(fmt.Sprintf("rlp.EncodeToBytes failed: %s", err))
	} else {
		err = s.db.Put(key.raw, rawEnvelope, nil)
		if err != nil {
			log.Error(fmt.Sprintf("Writing to DB failed: %s", err))
		}
	}
}
1054164
func (maildir *Maildir) Store(m *data.Message) (string, error) {
	b, err := ioutil.ReadAll(m.Raw.Bytes())
	if err != nil {
		return "", err
	}
	err = ioutil.WriteFile(filepath.Join(maildir.Path, string(m.ID)), b, 0660)
	return string(m.ID), err
}
104810
func (p *PodContainer) Storage(disk float64) *PodContainer {
	p.Resources.Disk = disk
	return p
}
727279
func NewArchiveBare(name string) Archive {
	return Archive{
		MetricDefinition: schema.MetricDefinition{
			Name: name,
		},
	}
}
1122248
func (p *ProjectCard) GetArchived() bool {
	if p == nil || p.Archived == nil {
		return false
	}
	return *p.Archived
}
1120723
func (p *PartitionedMemoryIdx) Get(key schema.MKey) (idx.Archive, bool) {
	g, _ := errgroup.WithContext(context.Background())
	resultChan := make(chan *idx.Archive, len(p.Partition))
	for _, m := range p.Partition {
		m := m
		g.Go(func() error {
			if a, ok := m.Get(key); ok {
				resultChan <- &a
			}
			return nil
		})
	}

	var err atomic.Value
	go func() {
		if e := g.Wait(); e != nil {
			err.Store(e)
		}
		close(resultChan)
	}()

	result, ok := <-resultChan
	if !ok {
		e := err.Load()
		if e != nil {
			log.Errorf("memory-idx: failed to get Archive with key %v. %s", key, e)
		}
		return idx.Archive{}, false
	}

	return *result, true
}
963264
func (s *ChannelsService) Archive(channel string) *ChannelsArchiveCall {
	var call ChannelsArchiveCall
	call.service = s
	call.channel = channel
	return &call
}
87723
func (env *maasEnviron) Storage() storage.Storage {
	env.ecfgMutex.Lock()
	defer env.ecfgMutex.Unlock()
	return env.storageUnlocked
}
820607
func (a Archive) Add(name, path string) error {
	if a.gw.Header.Name != "" {
		return fmt.Errorf("gzip: failed to add %s, only one file can be archived in gz format", name)
	}
	file, err := os.Open(path) // #nosec
	if err != nil {
		return err
	}
	defer file.Close() // nolint: errcheck
	info, err := file.Stat()
	if err != nil {
		return err
	}
	if info.IsDir() {
		return nil
	}
	a.gw.Header.Name = name
	a.gw.Header.ModTime = info.ModTime()
	_, err = io.Copy(a.gw, file)
	return err
}
466570
func (api *ArchiveAPI) Create(value *sacloud.Archive) (*sacloud.Archive, error) {
	return api.request(func(res *sacloud.Response) error {
		return api.create(api.createRequest(value), res)
	})
}
230384
func (v *Staggered) Archive(filePath string) error {
	l.Debugln("Waiting for lock on ", v.versionsFs)
	v.mutex.Lock()
	defer v.mutex.Unlock()

	if err := archiveFile(v.folderFs, v.versionsFs, filePath, TagFilename); err != nil {
		return err
	}

	file := filepath.Base(filePath)
	inFolderPath := filepath.Dir(filePath)

	// Glob according to the new file~timestamp.ext pattern.
	pattern := filepath.Join(inFolderPath, TagFilename(file, TimeGlob))
	newVersions, err := v.versionsFs.Glob(pattern)
	if err != nil {
		l.Warnln("globbing:", err, "for", pattern)
		return nil
	}

	// Also according to the old file.ext~timestamp pattern.
	pattern = filepath.Join(inFolderPath, file+"~"+TimeGlob)
	oldVersions, err := v.versionsFs.Glob(pattern)
	if err != nil {
		l.Warnln("globbing:", err, "for", pattern)
		return nil
	}

	// Use all the found filenames.
	versions := append(oldVersions, newVersions...)
	v.expire(util.UniqueStrings(versions))

	return nil
}
1283577
func (r *Application) Storage(disk float64) *Application {
	r.Disk = &disk
	return r
}
1160980
func Archive(m Manifest) error {
	// Wrap our log source in a safeLogEntrySource to protect our index order.
	m.Source = &safeLogEntrySource{
		Manifest: &m,
		Source:   m.Source,
	}

	// If no constraints are applied, index every LogEntry.
	if m.StreamIndexRange <= 0 && m.PrefixIndexRange <= 0 && m.ByteRange <= 0 {
		m.StreamIndexRange = 1
	}

	// If we're constructing an index, allocate a stateful index builder.
	var idx *indexBuilder
	if m.IndexWriter != nil {
		idx = &indexBuilder{
			Manifest: &m,
			index: logpb.LogIndex{
				Desc: m.Desc,
			},
			sizeFunc: m.sizeFunc,
		}
	}

	err := parallel.FanOutIn(func(taskC chan<- func() error) {
		var logC chan *logpb.LogEntry
		if m.LogWriter != nil {
			logC = make(chan *logpb.LogEntry)

			taskC <- func() error {
				if err := archiveLogs(m.LogWriter, m.Desc, logC, idx); err != nil {
					return err
				}

				// If we're building an index, emit it now that the log stream has
				// finished.
				if idx != nil {
					return idx.emit(m.IndexWriter)
				}
				return nil
			}
		}

		var dataC chan *logpb.LogEntry
		if m.DataWriter != nil {
			dataC = make(chan *logpb.LogEntry)

			taskC <- func() error {
				return archiveData(m.DataWriter, dataC)
			}
		}

		// Iterate through all of our Source's logs and process them.
		taskC <- func() error {
			if logC != nil {
				defer close(logC)
			}
			if dataC != nil {
				defer close(dataC)
			}

			sendLog := func(le *logpb.LogEntry) {
				if logC != nil {
					logC <- le
				}
				if dataC != nil {
					dataC <- le
				}
			}

			for {
				le, err := m.Source.NextLogEntry()
				if le != nil {
					sendLog(le)
				}

				if err != nil {
					if err == io.EOF {
						return nil
					}

					return err
				}

			}
		}
	})

	return err
}
982530
func Archive(arch *archiver.Archiver, opts *ArchiveOptions) *archiver.PendingItem {
	displayName := filepath.Base(opts.Isolated)
	defer tracer.Span(arch, strings.SplitN(displayName, ".", 2)[0]+":archive", nil)(nil)
	f, err := archive(arch, opts, displayName)
	if err != nil {
		i := &archiver.PendingItem{DisplayName: displayName}
		i.SetErr(err)
		return i
	}
	return f
}
1266068
func (p *PartitionedMemoryIdx) Prune(oldest time.Time) ([]idx.Archive, error) {
	// Prune each partition sequentially.
	result := []idx.Archive{}
	for _, m := range p.Partition {
		found, err := m.Prune(oldest)
		if err != nil {
			return result, err
		}
		result = append(result, found...)
	}
	return result, nil
}
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)
}
1035281
func (m *Migrator) archiveMDBStore() error {
	op := "Archiving LMDB data"
	m.sendProgress(op, 0, 1)

	if err := os.Rename(m.mdbPath, m.mdbBackupPath); err != nil {
		os.Remove(m.boltPath)
		return err
	}

	m.sendProgress(op, 1, 1)
	return nil
}