par1

package
v0.0.0-...-fb2d6dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2021 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

A Decoder keeps track of all information needed to check the integrity of a set of data files, and possibly repair any missing/corrupted data files from the parity files (.P00, .P01, etc.).

func NewDecoder

func NewDecoder(delegate DecoderDelegate, indexFile string) (*Decoder, error)

NewDecoder reads the given index file, which usually has a .PAR extension.

func (*Decoder) LoadFileData

func (d *Decoder) LoadFileData() error

LoadFileData loads existing file data into memory.

func (*Decoder) LoadParityData

func (d *Decoder) LoadParityData() error

LoadParityData searches for parity volumes and loads them into memory.

func (*Decoder) Repair

func (d *Decoder) Repair(checkParity bool) ([]string, error)

Repair tries to repair any missing or corrupted data, using the parity volumes. Returns a list of files that were successfully repaired, which is present even if an error is returned. If checkParity is true, extra checking is done of the reconstructed parity data.

func (*Decoder) Verify

func (d *Decoder) Verify() (needsRepair bool, err error)

Verify checks whether repair is needed. It returns a bool for needsRepair and an error; if error is non-nil, needsRepair may or may not be filled in.

type DecoderDelegate

type DecoderDelegate interface {
	OnHeaderLoad(headerInfo string)
	OnFileEntryLoad(i, n int, filename, entryInfo string)
	OnCommentLoad(comment []byte)
	OnDataFileLoad(i, n int, path string, byteCount int, corrupt bool, err error)
	OnDataFileWrite(i, n int, path string, byteCount int, err error)
	OnVolumeFileLoad(i uint64, path string, storedSetHash, computedSetHash [16]byte, dataByteCount int, err error)
}

DecoderDelegate holds methods that are called during the decode process.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

An Encoder keeps track of all information needed to create parity volumes for a set of data files, and write them out to parity files (.PAR, .P00, .P01, etc.).

func NewEncoder

func NewEncoder(delegate EncoderDelegate, filePaths []string, volumeCount int) (*Encoder, error)

NewEncoder creates an encoder with the given list of file paths, and with the given number of intended parity volumes.

func (*Encoder) ComputeParityData

func (e *Encoder) ComputeParityData() error

ComputeParityData computes the parity data for the files.

func (*Encoder) LoadFileData

func (e *Encoder) LoadFileData() error

LoadFileData loads the file data into memory.

func (*Encoder) Write

func (e *Encoder) Write(indexPath string) error

type EncoderDelegate

type EncoderDelegate interface {
	OnDataFileLoad(i, n int, path string, byteCount int, err error)
	OnVolumeFileWrite(i, n int, path string, dataByteCount, byteCount int, err error)
}

EncoderDelegate holds methods that are called during the encode process.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL