download

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MetadataSize = common.HashLength + 8 + 8

Variables

This section is empty.

Functions

This section is empty.

Types

type DownloadingDir added in v0.6.0

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

func CreateDownloadingDir added in v0.6.0

func CreateDownloadingDir(filename string) (*DownloadingDir, error)

CreateDownloadingDir creates a temporary downloading directory by renaming the existing directory if it exists or by creating a new one if it doesn't. It ensures files are stored in a safe temporary directory.

func (*DownloadingDir) Add added in v0.6.0

func (directory *DownloadingDir) Add(node *dir.FsNode, relpath string, persist func(path string) error) error

Add adds a file, directory, or symbolic link to the downloading directory.

func (*DownloadingDir) Seal added in v0.6.0

func (directory *DownloadingDir) Seal() error

Seal finalizes the downloading process by renaming the temporary directory back to its original name. It should be called after all files have been added to the directory.

type DownloadingFile

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

func CreateDownloadingFile

func CreateDownloadingFile(filename string, root common.Hash, size int64) (*DownloadingFile, error)

func (*DownloadingFile) Close

func (file *DownloadingFile) Close() error

func (*DownloadingFile) Metadata

func (file *DownloadingFile) Metadata() *Metadata

func (*DownloadingFile) Seal

func (file *DownloadingFile) Seal() error

func (*DownloadingFile) Write

func (file *DownloadingFile) Write(data []byte) error

type Metadata

type Metadata struct {
	Root   common.Hash // file merkle root
	Size   int64       // file size to download
	Offset int64       // offset to write for the next time
}

func DeserializeMedata

func DeserializeMedata(encoded []byte) (*Metadata, error)

func LoadMetadata

func LoadMetadata(file *os.File) (*Metadata, error)

func NewMetadata

func NewMetadata(root common.Hash, size int64) *Metadata

func (*Metadata) Extend

func (md *Metadata) Extend(file *os.File) error

func (*Metadata) Serialize

func (md *Metadata) Serialize() []byte

func (*Metadata) Write

func (md *Metadata) Write(file *os.File, data []byte) error

Jump to

Keyboard shortcuts

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