directory

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathSeparator = "/"
)

Variables

This section is empty.

Functions

func NewProtoDirectory

func NewProtoDirectory(dir *Directory) *proto.Directory

func NewProtoPath

func NewProtoPath(absolute string) *proto.Path

func NewProtoSearchMatch

func NewProtoSearchMatch(match SearchMatch) *proto.SearchMatch

func NewProtoSearchResponse

func NewProtoSearchResponse(matches []SearchMatch) *proto.SearchResponse

Types

type Directory

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

func NewDirectory

func NewDirectory(userId int32) *Directory

func (*Directory) AddFile

func (dir *Directory) AddFile(file *file.File, fp string) string

func (*Directory) AggregateFiles

func (dir *Directory) AggregateFiles(p string) map[string]*file.File

func (*Directory) FileByPath

func (dir *Directory) FileByPath(p string) *file.File

func (*Directory) FilesByPath

func (dir *Directory) FilesByPath(p string) map[string]*file.File

func (*Directory) RemoveFile

func (dir *Directory) RemoveFile(file *file.File)

func (*Directory) Search

func (dir *Directory) Search(search string) []SearchMatch

type DirectoryApplication

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

func NewDirectoryApplication

func NewDirectoryApplication(dirRepo DirectoryRepository, fileRepo file.FileRepository, logger *zap.Logger) *DirectoryApplication

func (*DirectoryApplication) Create

func (app *DirectoryApplication) Create(ctx context.Context, uid int32) (*Directory, error)

Create creates a new directory if, and only if, there is no other for the given user uid. Otherwise returns an error.

func (*DirectoryApplication) Delete

func (app *DirectoryApplication) Delete(ctx context.Context, uid int32, p string) (*Directory, error)

Delete removes from the directory all those files whose path matches the given one.

func (*DirectoryApplication) Get

func (app *DirectoryApplication) Get(ctx context.Context, uid int32, p string) (*Directory, error)

Get agregates into a list of files all those files matching the given path.

func (*DirectoryApplication) Move

func (app *DirectoryApplication) Move(ctx context.Context, uid int32, paths []string, dest string) (*Directory, error)

Move replaces the destination path to all these file paths in the directory matching any of the given paths.

func (*DirectoryApplication) RegisterFile

func (app *DirectoryApplication) RegisterFile(ctx context.Context, file *file.File, uid int32, fp string) (string, error)

RegisterFile registers the given file into the user uid directory. The given path may change if, and only if, another file with the same name exists in the same path.

func (*DirectoryApplication) Search

func (app *DirectoryApplication) Search(ctx context.Context, uid int32, regex string) ([]SearchMatch, error)

Search returns alls these files whose path matches with the given regex

func (*DirectoryApplication) UnregisterFile

func (app *DirectoryApplication) UnregisterFile(ctx context.Context, f *file.File, uid int32) error

UnregisterFile unregisters the given file from the directory. This action may trigger the file's deletion if it becomes with no owner once unregistered.

type DirectoryGrpcService

type DirectoryGrpcService struct {
	proto.UnimplementedDirectoryServiceServer
	// contains filtered or unexported fields
}

func NewDirectoryGrpcServer

func NewDirectoryGrpcServer(app *DirectoryApplication, logger *zap.Logger, authHeader string) *DirectoryGrpcService

func (*DirectoryGrpcService) Delete

func (server *DirectoryGrpcService) Delete(ctx context.Context, path *proto.Path) (*proto.Directory, error)

func (*DirectoryGrpcService) Get

func (server *DirectoryGrpcService) Get(ctx context.Context, path *proto.Path) (*proto.Directory, error)

func (*DirectoryGrpcService) Move

func (*DirectoryGrpcService) Search

type DirectoryRepository

type DirectoryRepository interface {
	FindByUserId(ctx context.Context, userId int32, options *RepoOptions) (*Directory, error)
	Create(ctx context.Context, directory *Directory) error
	Save(ctx context.Context, directory *Directory) error
	Delete(ctx context.Context, directory *Directory) error
}

type MongoDirectoryRepository

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

func NewMongoDirectoryRepository

func NewMongoDirectoryRepository(db *mongo.Database, fileRepo file.FileRepository, logger *zap.Logger) *MongoDirectoryRepository

func (*MongoDirectoryRepository) Create

func (repo *MongoDirectoryRepository) Create(ctx context.Context, dir *Directory) error

func (*MongoDirectoryRepository) Delete

func (repo *MongoDirectoryRepository) Delete(ctx context.Context, dir *Directory) error

func (*MongoDirectoryRepository) FindByUserId

func (repo *MongoDirectoryRepository) FindByUserId(ctx context.Context, userId int32, options *RepoOptions) (*Directory, error)

func (*MongoDirectoryRepository) Save

func (repo *MongoDirectoryRepository) Save(ctx context.Context, dir *Directory) error

type RepoOptions

type RepoOptions struct {
	LazyLoading bool
}

type SearchMatch

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

Jump to

Keyboard shortcuts

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