file

package
Version: v0.0.0-...-11f19c3 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 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
}

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
}

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
t or T : Toggle theme light dark auto
y or Y : Canonical URL