file

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: MIT Imports: 2 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
}

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) 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
}

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