func (bs *boltStorage) dropOldSnapshots(numberOfSnapshotsToKeep int) error {
	var k []byte
	tx, err := bs.db.Begin(true)
	if err != nil {
		return err
	}

	defer tx.Rollback()
	c := tx.Bucket(snapshotsBucket).Cursor()
	c.Last()
	for i := 0; i < numberOfSnapshotsToKeep; i++ {
		k, _ = c.Prev()
	}

	for k != nil {
		err = c.Delete()
		if err != nil {
			bs.logger.Errorf("Can't delete key %d: %s", bytesToUint64(k), err.Error())
		}

		k, _ = c.Prev()
	}

	err = tx.Commit()
	if err != nil {
		return err
	}

	return nil
}
// Drops all existing indexes and only keeps the latest snapshots.
Drops all existing indexes and only keeps the latest snapshots.
// Drops all existing indexes and only keeps the latest snapshots .
func (bs *boltStorage) dropOldSnapshots(numberOfSnapshotsToKeep int) error {
	var k []byte
	tx, err := bs.db.Begin(true)
	if err != nil {
		return err
	}
	defer tx.Rollback()
	c := tx.Bucket(snapshotsBucket).Cursor()
	c.Last()
	for i := 0; i < numberOfSnapshotsToKeep; i++ {
		k, _ = c.Prev()
	}
	for k != nil {
		err = c.Delete()
		if err != nil {
			bs.logger.Errorf("Can't delete key %d: %s", bytesToUint64(k), err.Error())
		}
		k, _ = c.Prev()
	}
	err = tx.Commit()
	if err != nil {
		return err
	}
	return nil
}
func ( bs * boltStorage ) dropOldSnapshots ( numberOfSnapshotsToKeep int ) error { var k [ ] byte tx , err := bs . db . Begin ( true ) if err != nil { return err } defer tx . Rollback ( ) c := tx . Bucket ( snapshotsBucket ) . Cursor ( ) c . Last ( ) for i := 0 ; i < numberOfSnapshotsToKeep ; i ++ { k , _ = c . Prev ( ) } for k != nil { err = c . Delete ( ) if err != nil { bs . logger . Errorf ( " " , bytesToUint64 ( k ) , err . Error ( ) ) } k , _ = c . Prev ( ) } err = tx . Commit ( ) if err != nil { return err } return nil }
Drops all existing indexes and only keeps the latest snapshots.
Drops all existing indexes and only keeps the latest snapshots .