storage

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFreeSpace added in v0.5.0

func CheckFreeSpace(dirPath string) (uint64, error)

CheckFreeSpace returns the available bytes on the volume containing the specified path.

func EnsureDirExists

func EnsureDirExists(path string) error

EnsureDirExists creates a directory if it doesn't exist.

func ResolveDuplicateFilename added in v0.4.0

func ResolveDuplicateFilename(dir, baseName string) string

ResolveDuplicateFilename finds an available filename by appending numbers if the file exists.

func SaveStreamToFile

func SaveStreamToFile(stream io.Reader, filePath string, onProgress func(bytesWritten int64)) error

SaveStreamToFile saves an io.Reader stream to a specified file path. It creates necessary directories. It reports progress via the onProgress callback (bytes written).

func SaveStreamToFileWithMetadata added in v0.2.0

func SaveStreamToFileWithMetadata(stream io.Reader, filePath string, fileSize int64, modified *string, accessed *string, expectedSha256 *string, onProgress func(bytesWritten int64), logger *zap.SugaredLogger) error

SaveStreamToFileWithMetadata saves an io.Reader stream and restores optional timestamps. If expectedSha256 is provided, the stream is verified against it after the copy succeeds. fileSize is used to select an optimal copy buffer size.

Types

type ProgressWriter

type ProgressWriter struct {
	Writer       io.Writer
	BytesWritten int64
	OnProgress   func(bytesWritten int64)
}

ProgressWriter is a wrapper around io.Writer that calls a callback on Write.

func (*ProgressWriter) Write

func (pw *ProgressWriter) Write(p []byte) (n int, err error)

Write implements the io.Writer interface.

Jump to

Keyboard shortcuts

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