// TruncateBefore removes all data prior to the given offset from disk.
// The last segment will always be kept.
TruncateBefore removes all data prior to the given offset from disk.
The last segment will always be kept.
// TruncateBefore removes all data prior to the given offset from disk . // The last segment will always be kept .
func (wal *WAL) TruncateBefore(o Offset) error {
	cutoff := sequenceToFilename(o.FileSequence())
	return wal.forEachSegment(func(file os.FileInfo, first bool, last bool) (bool, error) {
		if last || file.Name() >= cutoff {
			return false, nil
		}
		rmErr := os.Remove(filepath.Join(wal.dir, file.Name()))
		if rmErr != nil {
			return false, rmErr
		}
		wal.log.Debugf("Removed WAL file %v", filepath.Join(wal.dir, file.Name()))
		return true, nil
	})
}
func ( wal * WAL ) TruncateBefore ( o Offset ) error { cutoff := sequenceToFilename ( o . FileSequence ( ) ) return wal . forEachSegment ( func ( file os . FileInfo , first bool , last bool ) ( bool , error ) { if last || file . Name ( ) >= cutoff { return false , nil } rmErr := os . Remove ( filepath . Join ( wal . dir , file . Name ( ) ) ) if rmErr != nil { return false , rmErr } wal . log . Debugf ( " " , filepath . Join ( wal . dir , file . Name ( ) ) ) return true , nil } ) }
TruncateBefore removes all data prior to the given offset from disk.
TruncateBefore removes all data prior to the given offset from disk .
// Files are sorted by name, if we've gotten past the cutoff or // encountered the last (active) file, don't bother continuing.