mcpath

package
v0.0.0-...-7924924 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join

func Join(path string, elements ...string) string

Join takes a path that contains the project/user portions and returns the project path portion joined with elements. For example "/project-uuid/user-uuid/rest/of/path" joined with "dir1", "file.txt" will return "/rest/of/path/dir1/file.txt".

func ToProjectPath

func ToProjectPath(path string) string

ToProjectPath takes a path that contains the project/user portions and returns the project path. For example "/25/301/rest/of/path" will return "/rest/of/path".

Types

type Parser

type Parser interface {
	Parse(path string) (Path, error)
}

type ParserReleaser

type ParserReleaser interface {
	Parser
	Releaser
}

func NewTransferPathParser

func NewTransferPathParser(stors *stor.Stors, trCache *fsstate.TransferRequestCache) ParserReleaser

type Path

type Path interface {
	ProjectID() int
	UserID() int
	TransferID() int
	TransferKey() string
	ProjectPath() string
	FullPath() string
	TransferBase() string
	PathType() PathType
	TransferRequest() *mcmodel.TransferRequest
	Lookup() (*mcmodel.File, error)
	List() ([]mcmodel.File, error)
}

type PathType

type PathType int
const (
	RootPathType    PathType = 1
	ContextPathType PathType = 2
	ProjectPathType PathType = 3
	BadPathType     PathType = 4
)
const (
	RootBasePath     PathType = 10
	ProjectBasePath  PathType = 11
	UserBasePath     PathType = 12
	CompleteBasePath PathType = 13
	BadIDPath        PathType = 14
)

type ProjectPath

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

ProjectPath represents the different parts of a project path in the file system. Each project/user gets a unique path for upload/download. The path starts with the project ID and user ID, eg /25/301. The rest of the path is the directory tree for that project. In the database paths are stored without the project/user id, eg /25/301/dir1/file.txt has path /dir1/file.txt.

The methods for ProjectPath help with these two representations

func (*ProjectPath) FullPath

func (p *ProjectPath) FullPath() string

func (*ProjectPath) FullPathJoin

func (p *ProjectPath) FullPathJoin(elements ...string) string

FullPathJoin will return the joined path elements onto the ProjectPath.FullPath, for example if ProjectPath.FullPath is "/25/301/dir1/dir2", and you join "dir3", "file.txt" it will return "/25/301/dir1/dir2/dir3/file.txt".

func (*ProjectPath) Join

func (p *ProjectPath) Join(elements ...string) string

Join will return the joined path elements onto the ProjectPath.ProjectPath, for example if ProjectPath.ProjectPath is "/dir1/dir2", and you join "dir3", "file.txt" it will return "/dir1/dir2/dir3/file.txt".

func (*ProjectPath) List

func (p *ProjectPath) List() ([]mcmodel.File, error)

func (*ProjectPath) Lookup

func (p *ProjectPath) Lookup() (*mcmodel.File, error)

func (*ProjectPath) PathType

func (p *ProjectPath) PathType() PathType

func (*ProjectPath) ProjectID

func (p *ProjectPath) ProjectID() int

func (*ProjectPath) ProjectPath

func (p *ProjectPath) ProjectPath() string

func (*ProjectPath) TransferBase

func (p *ProjectPath) TransferBase() string

func (*ProjectPath) TransferID

func (p *ProjectPath) TransferID() int

func (*ProjectPath) TransferKey

func (p *ProjectPath) TransferKey() string

func (*ProjectPath) TransferRequest

func (p *ProjectPath) TransferRequest() *mcmodel.TransferRequest

func (*ProjectPath) UserID

func (p *ProjectPath) UserID() int

type ProjectPathParser

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

func NewProjectPathParser

func NewProjectPathParser(stors *stor.Stors) *ProjectPathParser

func (*ProjectPathParser) Parse

func (p *ProjectPathParser) Parse(path string) (Path, error)

Parse takes a path containing the project and user uuid and creates a ProjectPath structure containing the various parts of the path. A path consists of /project-id/user-id/rest/of/path. From this path it constructs ProjectPath that would look as follows for /25/301/rest/of/path

&ProjecPath{
    ProjectID: 25
    UserUUID: 301
    ProjectPath: /rest/of/path
    FullPath: /25/301/rest/of/path
}

type Releaser

type Releaser interface {
	Release(path string)
}

type TransferPath

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

func (*TransferPath) FullPath

func (p *TransferPath) FullPath() string

func (*TransferPath) List

func (p *TransferPath) List() ([]mcmodel.File, error)

func (*TransferPath) Lookup

func (p *TransferPath) Lookup() (*mcmodel.File, error)

func (*TransferPath) PathType

func (p *TransferPath) PathType() PathType

func (*TransferPath) ProjectID

func (p *TransferPath) ProjectID() int

func (*TransferPath) ProjectPath

func (p *TransferPath) ProjectPath() string

func (*TransferPath) TransferBase

func (p *TransferPath) TransferBase() string

func (*TransferPath) TransferID

func (p *TransferPath) TransferID() int

func (*TransferPath) TransferKey

func (p *TransferPath) TransferKey() string

func (*TransferPath) TransferRequest

func (p *TransferPath) TransferRequest() *mcmodel.TransferRequest

func (*TransferPath) UserID

func (p *TransferPath) UserID() int

type TransferPathParser

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

func (*TransferPathParser) Parse

func (p *TransferPathParser) Parse(path string) (Path, error)

func (*TransferPathParser) Release

func (p *TransferPathParser) Release(path string)

TODO: Can this be removed?

Jump to

Keyboard shortcuts

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