model

package
v0.5.15 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 11 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BufferPool = sync.Pool{
	New: func() any {
		return bytes.NewBuffer(make([]byte, 4*1024))
	},
}

BufferPool for io.CopyBuffer

Functions

func Dirname

func Dirname(name string) string

Dirname ensures given name is a dirname, with a trailing slash

func ErrNotExist

func ErrNotExist(err error) error

ErrNotExist create a NotExist error

func HandleClose added in v0.0.5

func HandleClose(closer io.Closer, err error) error

HandleClose call properly

func ID added in v0.4.3

func ID(pathname string) string

ID computes id of given pathname

func IsNotExist

func IsNotExist(err error) bool

IsNotExist checks if error match a not found

Types

type Item

type Item struct {
	Date      time.Time `json:"date"`
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Pathname  string    `json:"pathname"`
	Extension string    `json:"extension"`
	IsDir     bool      `json:"isDir"`
	Size      int64     `json:"size"`
}

Item describe item on a storage provider

func (Item) Dir

func (s Item) Dir() string

Dir return the nearest directory (self of parent)

type Storage

type Storage interface {
	Enabled() bool
	Name() string
	WithIgnoreFn(ignoreFn func(Item) bool) Storage
	Path(pathname string) string
	Info(ctx context.Context, pathname string) (Item, error)
	List(ctx context.Context, pathname string) ([]Item, error)
	WriteTo(ctx context.Context, pathname string, reader io.Reader) error
	WriteSizedTo(ctx context.Context, pathname string, size int64, reader io.Reader) error
	ReadFrom(ctx context.Context, pathname string) (io.ReadSeekCloser, error)
	Walk(ctx context.Context, pathname string, walkFn func(Item) error) error
	CreateDir(ctx context.Context, pathname string) error
	Rename(ctx context.Context, oldName, newName string) error
	Remove(ctx context.Context, pathname string) error
	UpdateDate(ctx context.Context, pathname string, date time.Time) error
	ConvertError(err error) error
}

Storage describe action on a storage provider

Jump to

Keyboard shortcuts

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