file_snapshot.go
func (s *FileSnapshotSink) writeMeta() error {
	// Open the meta file
	metaPath := filepath.Join(s.dir, metaFilePath)
	fh, err := os.Create(metaPath)
	if err != nil {
		return err
	}
	defer fh.Close()

	// Buffer the file IO
	buffered := bufio.NewWriter(fh)

	// Write out as JSON
	enc := json.NewEncoder(buffered)
	if err := enc.Encode(&s.meta); err != nil {
		return err
	}

	if err = buffered.Flush(); err != nil {
		return err
	}

	if err = fh.Sync(); err != nil {
		return err
	}

	return nil
}
func (s *FileSnapshotSink) writeMeta() error {
	// Open the meta file
	metaPath := filepath.Join(s.dir, metaFilePath)
	fh, err := os.Create(metaPath)
	if err != nil {
		return err
	}
	defer fh.Close()

	// Buffer the file IO
	buffered := bufio.NewWriter(fh)

	// Write out as JSON
	enc := json.NewEncoder(buffered)
	if err := enc.Encode(&s.meta); err != nil {
		return err
	}

	if err = buffered.Flush(); err != nil {
		return err
	}

	if err = fh.Sync(); err != nil {
		return err
	}

	return nil
}
func ( s * FileSnapshotSink ) writeMeta ( ) error { // Open the meta file metaPath := filepath . Join ( s . dir , metaFilePath ) fh , err := os . Create ( metaPath ) if err != nil { return err } defer fh . Close ( ) // Buffer the file IO buffered := bufio . NewWriter ( fh ) // Write out as JSON enc := json . NewEncoder ( buffered ) if err := enc . Encode ( & s . meta ) ; err != nil { return err } if err = buffered . Flush ( ) ; err != nil { return err } if err = fh . Sync ( ) ; err != nil { return err } return nil }
// writeMeta is used to write out the metadata we have.
writeMeta is used to write out the metadata we have .