Пример #1
0
func Clear(dbpath string, stop uint64, closed []uint64) error {
	tmp, err := stream.New("tmp.stream")
	if err != nil {
		return err
	}

	if err = tmp.Close(); err != nil {
		return err
	}

	for _, commit := range closed {
		fmt.Println("commit", commit)
		if commit < stop {
			path := filepath.Join(dbpath, "stream", fmt.Sprintf("events.%024v.stream", commit))
			fmt.Println("clearing", path)
			err := exec.Command("cp", "-f", "tmp.stream", path).Run()
			if err != nil {
				return err
			}
		}
	}

	os.Remove("tmp.stream")

	return nil
}
Пример #2
0
func (db *DB) setCurrent(commit uint64) {
	db.current = commit
	db.mockoffset = 10

	err := os.Remove(db.reader.Path(commit))
	if err != nil && !strings.Contains(err.Error(), "no such file or directory") {
		log.Fatal(err)
	}

	s, err := stream.New(db.reader.Path(commit))
	if err != nil {
		log.Fatal(err)
	}

	db.stream = s

	log.Println("STREAM: Creating", db.current)
}