dfs

package
v0.0.0-...-059fb3b Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSpaceName = "My files"
View Source
const NoParent = uuid.UUID("00000000-0000-0000-0000-00000000000")
View Source
const WalkBatchSize = 100

Variables

View Source
var (
	ErrNotImplemented  = errors.New("not implemented")
	ErrInvalidPath     = errors.New("invalid path")
	ErrInvalidRoot     = errors.New("invalid root")
	ErrInvalidParent   = errors.New("invalid parent")
	ErrInvalidMimeType = errors.New("invalid mime type")
	ErrIsNotDir        = errors.New("not a directory")
	ErrIsADir          = errors.New("is a directory")
	ErrNotFound        = errors.New("inode not found")
	ErrAlreadyExists   = errors.New("already exists")
)
View Source
var ExampleAliceNewFile = INode{
	// contains filtered or unexported fields
}
View Source
var ExampleAliceRenamedFile = INode{
	// contains filtered or unexported fields
}

Functions

func CleanPath

func CleanPath(name string) string

CleanPath is equivalent to but slightly more efficient than path.Clean("/" + name).

func Walk

func Walk(ctx context.Context, ffs Service, cmd *PathCmd, fn WalkDirFunc) error

Types

type CreateDirCmd

type CreateDirCmd struct {
	Path      *PathCmd
	CreatedBy *users.User
}

func (CreateDirCmd) Validate

func (t CreateDirCmd) Validate() error

type CreateRootDirCmd

type CreateRootDirCmd struct {
	CreatedBy *users.User
	Space     *spaces.Space
}

func (CreateRootDirCmd) Validate

func (t CreateRootDirCmd) Validate() error

type FSGGCTaskRunner

type FSGGCTaskRunner struct {
	// contains filtered or unexported fields
}

func NewFSGGCTaskRunner

func NewFSGGCTaskRunner(
	storage storage,
	files files.Service,
	spaces spaces.Service,
	scheduler scheduler.Service,
	tools tools.Tools,
) *FSGGCTaskRunner

func (*FSGGCTaskRunner) Name

func (r *FSGGCTaskRunner) Name() string

func (*FSGGCTaskRunner) Run

func (r *FSGGCTaskRunner) Run(ctx context.Context, rawArgs json.RawMessage) error

func (*FSGGCTaskRunner) RunArgs

func (r *FSGGCTaskRunner) RunArgs(ctx context.Context, args *scheduler.FSGCArgs) error

type FSMoveTaskRunner

type FSMoveTaskRunner struct {
	// contains filtered or unexported fields
}

func NewFSMoveTaskRunner

func NewFSMoveTaskRunner(fs Service, storage storage, spaces spaces.Service, users users.Service, scheduler scheduler.Service) *FSMoveTaskRunner

func (*FSMoveTaskRunner) Name

func (r *FSMoveTaskRunner) Name() string

func (*FSMoveTaskRunner) Run

func (r *FSMoveTaskRunner) Run(ctx context.Context, rawArgs json.RawMessage) error

func (*FSMoveTaskRunner) RunArgs

func (r *FSMoveTaskRunner) RunArgs(ctx context.Context, args *scheduler.FSMoveArgs) error

type FSRefreshSizeTaskRunner

type FSRefreshSizeTaskRunner struct {
	// contains filtered or unexported fields
}

func NewFSRefreshSizeTaskRunner

func NewFSRefreshSizeTaskRunner(storage storage, files files.Service, stats stats.Service) *FSRefreshSizeTaskRunner

func (*FSRefreshSizeTaskRunner) Name

func (r *FSRefreshSizeTaskRunner) Name() string

func (*FSRefreshSizeTaskRunner) Run

func (*FSRefreshSizeTaskRunner) RunArgs

type FSRemoveDuplicateFilesRunner

type FSRemoveDuplicateFilesRunner struct {
	// contains filtered or unexported fields
}

func NewFSRemoveDuplicateFileRunner

func NewFSRemoveDuplicateFileRunner(storage storage, files files.Service, scheduler scheduler.Service) *FSRemoveDuplicateFilesRunner

func (*FSRemoveDuplicateFilesRunner) Name

func (*FSRemoveDuplicateFilesRunner) Run

func (*FSRemoveDuplicateFilesRunner) RunArgs

type FakeINodeBuilder

type FakeINodeBuilder struct {
	// contains filtered or unexported fields
}

func NewFakeINode

func NewFakeINode(t *testing.T) *FakeINodeBuilder

func (*FakeINodeBuilder) Build

func (f *FakeINodeBuilder) Build() *INode

func (*FakeINodeBuilder) BuildAndStore

func (f *FakeINodeBuilder) BuildAndStore(ctx context.Context, db *sql.DB) *INode

func (*FakeINodeBuilder) CreatedAt

func (f *FakeINodeBuilder) CreatedAt(t time.Time) *FakeINodeBuilder

func (*FakeINodeBuilder) CreatedBy

func (f *FakeINodeBuilder) CreatedBy(user *users.User) *FakeINodeBuilder

func (*FakeINodeBuilder) IsRootDirectory

func (f *FakeINodeBuilder) IsRootDirectory() *FakeINodeBuilder

func (*FakeINodeBuilder) WithFile

func (f *FakeINodeBuilder) WithFile(file *files.FileMeta) *FakeINodeBuilder

func (*FakeINodeBuilder) WithID

func (f *FakeINodeBuilder) WithID(id string) *FakeINodeBuilder

func (*FakeINodeBuilder) WithName

func (f *FakeINodeBuilder) WithName(name string) *FakeINodeBuilder

func (*FakeINodeBuilder) WithParent

func (f *FakeINodeBuilder) WithParent(inode *INode) *FakeINodeBuilder

func (*FakeINodeBuilder) WithSpace

func (f *FakeINodeBuilder) WithSpace(space *spaces.Space) *FakeINodeBuilder

type INode

type INode struct {
	// contains filtered or unexported fields
}
var ExampleAliceDir INode = INode{
	// contains filtered or unexported fields
}
var ExampleAliceEmptyDir INode = INode{
	// contains filtered or unexported fields
}
var ExampleAliceFile INode = INode{
	// contains filtered or unexported fields
}
var ExampleAliceFile2 INode = INode{
	// contains filtered or unexported fields
}
var ExampleAliceRoot INode = INode{
	// contains filtered or unexported fields
}
var ExampleBobRoot INode = INode{
	// contains filtered or unexported fields
}

func (INode) CreatedAt

func (n INode) CreatedAt() time.Time

func (INode) CreatedBy

func (n INode) CreatedBy() uuid.UUID

func (INode) FileID

func (n INode) FileID() *uuid.UUID

func (INode) ID

func (n INode) ID() uuid.UUID

func (INode) IsDir

func (n INode) IsDir() bool

func (INode) LastModifiedAt

func (n INode) LastModifiedAt() time.Time

func (INode) Name

func (n INode) Name() string

func (INode) Parent

func (n INode) Parent() *uuid.UUID

func (INode) Size

func (n INode) Size() uint64

func (INode) SpaceID

func (n INode) SpaceID() uuid.UUID

type MockService

type MockService struct {
	mock.Mock
}

MockService is an autogenerated mock type for the Service type

func NewMockService

func NewMockService(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockService

NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockService) CreateDir

func (_m *MockService) CreateDir(ctx context.Context, cmd *CreateDirCmd) (*INode, error)

CreateDir provides a mock function with given fields: ctx, cmd

func (*MockService) CreateFS

func (_m *MockService) CreateFS(ctx context.Context, user *users.User, space *spaces.Space) (*INode, error)

CreateFS provides a mock function with given fields: ctx, user, space

func (*MockService) Destroy

func (_m *MockService) Destroy(ctx context.Context, user *users.User, space *spaces.Space) error

Destroy provides a mock function with given fields: ctx, user, space

func (*MockService) Download

func (_m *MockService) Download(ctx context.Context, cmd *PathCmd) (io.ReadSeekCloser, error)

Download provides a mock function with given fields: ctx, cmd

func (*MockService) Get

func (_m *MockService) Get(ctx context.Context, cmd *PathCmd) (*INode, error)

Get provides a mock function with given fields: ctx, cmd

func (*MockService) ListDir

func (_m *MockService) ListDir(ctx context.Context, cmd *PathCmd, paginateCmd *sqlstorage.PaginateCmd) ([]INode, error)

ListDir provides a mock function with given fields: ctx, cmd, paginateCmd

func (*MockService) Move

func (_m *MockService) Move(ctx context.Context, cmd *MoveCmd) error

Move provides a mock function with given fields: ctx, cmd

func (*MockService) Remove

func (_m *MockService) Remove(ctx context.Context, cmd *PathCmd) error

Remove provides a mock function with given fields: ctx, cmd

func (*MockService) Rename

func (_m *MockService) Rename(ctx context.Context, inode *INode, newName string) (*INode, error)

Rename provides a mock function with given fields: ctx, inode, newName

func (*MockService) Upload

func (_m *MockService) Upload(ctx context.Context, cmd *UploadCmd) error

Upload provides a mock function with given fields: ctx, cmd

type MoveCmd

type MoveCmd struct {
	Src     *PathCmd
	Dst     *PathCmd
	MovedBy *users.User
}

func (MoveCmd) Validate

func (t MoveCmd) Validate() error

type PathCmd

type PathCmd struct {
	// contains filtered or unexported fields
}

func NewPathCmd

func NewPathCmd(space *spaces.Space, path string) *PathCmd

func (PathCmd) Contains

func (t PathCmd) Contains(p PathCmd) bool

Contains returns true if the the arg `p` point to the same element or an element contained by `t`.

"/foo".Contains("/foo/") -> true "/foo/bar".Contains("/foo") -> false "/foo".Contains("/foo/bar") -> true

func (PathCmd) Equal

func (t PathCmd) Equal(p PathCmd) bool

func (PathCmd) Path

func (t PathCmd) Path() string

func (PathCmd) Space

func (t PathCmd) Space() *spaces.Space

func (PathCmd) String

func (t PathCmd) String() string

func (PathCmd) Validate

func (t PathCmd) Validate() error

Validate the fields.

type Result

type Result struct {
	fx.Out
	Service                      Service
	FSGCTask                     runner.TaskRunner `group:"tasks"`
	FSMoveTask                   runner.TaskRunner `group:"tasks"`
	FSRefreshSizeTask            runner.TaskRunner `group:"tasks"`
	FSRemoveDuplicateFilesRunner runner.TaskRunner `group:"tasks"`
}

func Init

func Init(db *sql.DB,
	spaces spaces.Service,
	files files.Service,
	scheduler scheduler.Service,
	users users.Service,
	tools tools.Tools,
	stats stats.Service,
) (Result,
	error,
)

type Service

type Service interface {
	Destroy(ctx context.Context, user *users.User, space *spaces.Space) error
	CreateFS(ctx context.Context, user *users.User, space *spaces.Space) (*INode, error)
	CreateDir(ctx context.Context, cmd *CreateDirCmd) (*INode, error)
	ListDir(ctx context.Context, cmd *PathCmd, paginateCmd *sqlstorage.PaginateCmd) ([]INode, error)
	Remove(ctx context.Context, cmd *PathCmd) error
	Rename(ctx context.Context, inode *INode, newName string) (*INode, error)
	Move(ctx context.Context, cmd *MoveCmd) error
	Get(ctx context.Context, cmd *PathCmd) (*INode, error)
	Upload(ctx context.Context, cmd *UploadCmd) error
	Download(ctx context.Context, cmd *PathCmd) (io.ReadSeekCloser, error)
	// contains filtered or unexported methods
}

type UploadCmd

type UploadCmd struct {
	Content    io.Reader
	Path       *PathCmd
	UploadedBy *users.User
}

func (UploadCmd) Validate

func (t UploadCmd) Validate() error

type WalkDirFunc

type WalkDirFunc func(ctx context.Context, path string, i *INode) error

Jump to

Keyboard shortcuts

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