file

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path(base, sig string) string

Path calculates the storage path for the File with the Signature

Types

type File

type File struct {
	// Keys has all the keys that point to this file
	Keys []string

	// Signature is the SHA1 of the file
	Signature string

	// Replica number of replicas for that file
	Replica int

	// VolumeIDs it's where this file it's replicated to
	VolumeIDs []string

	// Is the size of the object in bytes
	Size int

	// TTL is the duration the file has before it'll be automatically deleted
	// if 0 it means it has no expiration
	TTL time.Duration

	// CreatedAt is the time in which the object was created originally
	CreatedAt time.Time
}

File represents the structure of a stored File with the Signature (SHA1 of the content of the File) and the key which is the name of the file

func (*File) DeleteVolumeID

func (f *File) DeleteVolumeID(vid string)

DeleteVolumeID removes the vid from the f.VolumeIDs if it does not exists it'll do nothing

func (*File) ExpiresAt added in v0.4.0

func (f *File) ExpiresAt() time.Time

ExpiresAt returns the expiration date of the File based on the CreatedAt and the TTL

func (File) Path

func (f File) Path(p string) string

Path calculates the storage path for the File with the Signature

type Repository

type Repository interface {
	CreateOrReplace(ctx context.Context, f *File) error
	FindBySignature(ctx context.Context, sig string) (*File, error)
	DeleteBySignature(ctx context.Context, sig string) error
	DeleteAll(ctx context.Context) error
	All(ctx context.Context) ([]*File, error)
}

Repository is the interface that has to be fulfiled to interact with Files

Jump to

Keyboard shortcuts

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