fs

package
v0.0.0-...-6178a5e Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessAllowed

func AccessAllowed(user *models.User, node *models.Node, write bool) bool

Checks if the given user has access to the given node.

func Copy

func Copy(ctx context.Context, src *models.Node, parent *models.Node, filename string,
	homeRoot, thumbRoot string, user *models.User,
	tx *sql.Tx) ([]*models.Node, error)

func CopyData

func CopyData(ctx context.Context, node *models.Node, sourceFile string, homeRoot string, tx *sql.Tx) error

Copy data to a node from source file.

func CopyFile

func CopyFile(srcPath, dstPath string) error

CopyFile copies while from srcPath to dstPath.

func Delete

func Delete(ctx context.Context, node *models.Node, recursive bool,
	user *models.User, homeRoot, thumbRoot string, tx boil.ContextExecutor) ([]*models.Node, error)

Delete a filesystem node.

func DetectMimeType

func DetectMimeType(filename string) (string, error)

Returns the mime type of a file or a default type.

func IsDir

func IsDir(node *models.Node) bool

IsDir returns true if the given node is a directory.

func IsValidName

func IsValidName(filename string) bool

IsValidName returns true if the given filename is valid.

func MakeDir

func MakeDir(ctx context.Context, parent *models.Node, filename string,
	user *models.User, homeRoot string, dontCreatePhys bool,
	tx boil.ContextExecutor) (*models.Node, error)

MakeDir creates a filesystem directory.

func Move

func Move(ctx context.Context, node *models.Node, dest *models.Node,
	user *models.User, homeRoot string, tx *sql.Tx) error

Move a node src under the dest directory node.

func NewFile

func NewFile(ctx context.Context, parent *models.Node, filename,
	mimeType string, size int64, owner *models.User,
	length *float64, hasCustomThumb bool, tx boil.ContextExecutor) (*models.Node, error)

func NodeByID

func NodeByID(ctx context.Context, id int, db boil.ContextExecutor) (*models.Node, error)

NodeByID returns a node by ID.

func NodeByIDopt

func NodeByIDopt(ctx context.Context, id int, db boil.ContextExecutor) (*models.Node, error)

NodeByIDopt returns a node by ID or nil if not found.

func NodeByPath

func NodeByPath(ctx context.Context, path string, root *models.Node, tx boil.ContextExecutor) (*models.Node, error)

NodeByPath parses a path and tries to find a node matching it. Returns nil, nil for not found error.

func NodeChildByName

func NodeChildByName(ctx context.Context, name string, parentID int, tx boil.ContextExecutor) (*models.Node, error)

NodeChildByName returns a child with the given name in the parent node. Returns nil, nil for not found error.

func NodesAll

func NodesAll(ctx context.Context, db boil.ContextExecutor) ([]*models.Node, error)

Returns all nodes.

func NodesByParentID

func NodesByParentID(ctx context.Context, parentID int, db boil.ContextExecutor) ([]*models.Node, error)

NodesByParentID returns nodes with the given parent ID.

func PathFor

func PathFor(ctx context.Context, node *models.Node, tx boil.ContextExecutor) (string, error)

PathFor returns a full path for a node.

func PhysPath

func PhysPath(ctx context.Context, node *models.Node, homeRoot string, tx boil.ContextExecutor) (string, error)

PhysPath returns full path for a node. It queries nodes recursive upwards until it finds a stored path or ends up at the root.

func Rename

func Rename(ctx context.Context, node *models.Node, filename string, user *models.User,
	homeRoot string, tx *sql.Tx) error

Rename a filesystem node.

func ThumbPath

func ThumbPath(root string, id int, includeFile bool) string

ThumbPath returns path for a thumbnail file. If includeFile is true, the filename is included in the path, otherwise the directory is returned, without trailing slash.

func UpdateFile

func UpdateFile(ctx context.Context, node *models.Node,
	mimeType string, size int64, owner *models.User,
	length *float64, hasCustomThumb bool, tx boil.ContextExecutor) error

Update data on an existing node. Does not update the filename or parent ID.

Types

type NodeWithProgress

type NodeWithProgress struct {
	models.Node `boil:",bind"`
	Progress    null.Float32 `boil:"progress.progress" json:"progress"`
	Volume      null.Float32 `boil:"progress.volume" json:"volume"`
}

NodeWithProgress contains models.Node data and associated progress data..

func NodeWithProgressByID

func NodeWithProgressByID(ctx context.Context, nodeID, userID int, db boil.ContextExecutor) (*NodeWithProgress, error)

NodeWithProgressByID returns a node with progress information.

func NodesWithProgressByParentID

func NodesWithProgressByParentID(ctx context.Context, parentID, userID int, db boil.ContextExecutor) ([]*NodeWithProgress, error)

NodesWithProgressByParentID returns nodes with progress information.

Jump to

Keyboard shortcuts

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