node

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileTypeFile a file
	FileTypeFile = "file"
	// FileTypeDir a directory
	FileTypeDir = "dir"
	// FileTypeStorage a storage
	FileTypeStorage = "storage"
	// FileTypeArchive a file archive
	FileTypeArchive = "archive"
	// FileTypeArchived an archived file
	FileTypeArchived = "archived"
)

Variables

This section is empty.

Functions

func DeriveStorageID

func DeriveStorageID(name string) int

DeriveStorageID derive id from storage name

func IsDir

func IsDir(n Node) bool

IsDir returns true if node is a directory

func IsModeDir

func IsModeDir(n Node) bool

IsModeDir returns true if mode is a directory

func IsStorage

func IsStorage(n Node) bool

IsStorage returns true if node is storage

func MayHaveChildren

func MayHaveChildren(n Node) bool

MayHaveChildren returns true if the node may have children

func ShouldDescendForRecSize

func ShouldDescendForRecSize(n Node) bool

ShouldDescendForRecSize returns true if the node may have children for recursive size calculation

Types

type FileNode

type FileNode struct {
	ID        string      `json:"id" toml:"id"`
	Name      string      `json:"name" toml:"name"`
	RelPath   string      `json:"relpath" toml:"relpath"` // to the storage node
	Checksum  string      `json:"md5" toml:"md5"`
	Type      FileType    `json:"filetype" toml:"filetype"`
	Size      uint64      `json:"size" toml:"size"`
	Maccess   int64       `json:"maccess" toml:"maccess"`
	Children  []*FileNode `json:"children" toml:"children"`
	IndexedAt int64       `json:"ts" toml:"ts"`
	StorageID int         `json:"storage_id" toml:"storage_id"`
	Mode      string      `json:"mode" toml:"mode"`
	Mime      string      `json:"mime" toml:"mime"`
	Extra     string      `json:"extra" toml:"extra"` // comma separated list of `<key>:<value>`
	// contains filtered or unexported fields
}

FileNode a file node

func NewArchivedFileNode

func NewArchivedFileNode(storageID int, path string, info fs.FileInfo, nameInsideArchive string) *FileNode

NewArchivedFileNode creates a new archived file node

func NewFileNode

func NewFileNode(storageID int, path string, info fs.FileInfo) *FileNode

NewFileNode creates a new file node

func (*FileNode) AddChild

func (n *FileNode) AddChild(child *FileNode)

AddChild adds a child to this node

func (*FileNode) GetAttr

func (n *FileNode) GetAttr(rawSize bool, long bool) map[string]string

GetAttr returns the node attribute as string

func (*FileNode) GetDirectChildren

func (n *FileNode) GetDirectChildren() map[string]*FileNode

GetDirectChildren returns this node children

func (*FileNode) GetMAccess

func (n *FileNode) GetMAccess() int64

GetMAccess returns node modification date

func (*FileNode) GetMode

func (n *FileNode) GetMode() string

GetMode returns node mode

func (*FileNode) GetName

func (n *FileNode) GetName() string

GetName returns this node name

func (*FileNode) GetPath

func (n *FileNode) GetPath() string

GetPath returns the node relative path to its parent

func (*FileNode) GetSize

func (n *FileNode) GetSize() uint64

GetSize returns this node size

func (*FileNode) GetSortedDirectChildren

func (n *FileNode) GetSortedDirectChildren() []*FileNode

GetSortedDirectChildren returns children sorted by names

func (*FileNode) GetType

func (n *FileNode) GetType() FileType

GetType returns the node type

func (*FileNode) IsExec

func (n *FileNode) IsExec() bool

IsExec is file executable

func (*FileNode) RemoveChild

func (n *FileNode) RemoveChild(removeMe Node)

RemoveChild removes a child from this node

func (*FileNode) Seen

func (n *FileNode) Seen() bool

Seen boolean to indicate if node was seen last update

func (*FileNode) SetSize

func (n *FileNode) SetSize(size uint64)

SetSize sets the node size field

func (*FileNode) Update

func (n *FileNode) Update(info fs.FileInfo)

Update updates the node info

type FileType

type FileType string

FileType node file type

type Node

type Node interface {
	GetName() string
	GetDirectChildren() map[string]*FileNode
	GetSortedDirectChildren() []*FileNode
	GetPath() string
	GetType() FileType
	GetMAccess() int64
	GetMode() string
	GetAttr(bool, bool) map[string]string // rawsize, long
	GetSize() uint64
	SetSize(uint64)
	Seen() bool
	AddChild(*FileNode)
	RemoveChild(Node)
}

Node generic node interface

type StorageNode

type StorageNode struct {
	ID         int         `json:"id" toml:"id"`
	Name       string      `json:"name" toml:"name"`
	Path       string      `json:"path" toml:"path"`
	Size       uint64      `json:"size" toml:"size"`
	Free       uint64      `json:"free" toml:"free"`
	Total      uint64      `json:"total" toml:"total"`
	IndexedAt  int64       `json:"ts" toml:"ts"`
	Type       FileType    `json:"type" toml:"type"`
	Tags       []string    `json:"tags" toml:"tags"`
	Meta       string      `json:"meta" toml:"meta"`
	TotalFiles uint64      `json:"nb_files" toml:"nb_files"`
	Children   []*FileNode `json:"children" toml:"children"`
}

StorageNode a storage node

func NewStorageNode

func NewStorageNode(name string, fsPath string, path string, meta string, tags []string) *StorageNode

NewStorageNode creates a new storage node

func (*StorageNode) AddChild

func (n *StorageNode) AddChild(child *FileNode)

AddChild adds a new child to this node

func (*StorageNode) GetAttr

func (n *StorageNode) GetAttr(rawSize bool, long bool) map[string]string

GetAttr returns the node attribute as string

func (*StorageNode) GetDirectChildren

func (n *StorageNode) GetDirectChildren() map[string]*FileNode

GetDirectChildren returns this node children

func (*StorageNode) GetMAccess

func (n *StorageNode) GetMAccess() int64

GetMAccess returns node modification date

func (*StorageNode) GetMode

func (n *StorageNode) GetMode() string

GetMode returns the storage mode

func (*StorageNode) GetName

func (n *StorageNode) GetName() string

GetName returns this node name

func (*StorageNode) GetPath

func (n *StorageNode) GetPath() string

GetPath returns the node relative path

func (*StorageNode) GetSize

func (n *StorageNode) GetSize() uint64

GetSize returns this node size

func (*StorageNode) GetSortedDirectChildren

func (n *StorageNode) GetSortedDirectChildren() []*FileNode

GetSortedDirectChildren returns children sorted by names

func (*StorageNode) GetType

func (n *StorageNode) GetType() FileType

GetType returns the node type

func (*StorageNode) IsDir

func (n *StorageNode) IsDir() bool

IsDir returns true if can enter

func (*StorageNode) RecursiveFillSize

func (n *StorageNode) RecursiveFillSize()

RecursiveFillSize recusively fills each node total size

func (*StorageNode) RemoveChild

func (n *StorageNode) RemoveChild(removeMe Node)

RemoveChild removes a child from this node

func (*StorageNode) Seen

func (n *StorageNode) Seen() bool

Seen boolean to indicate if node was seen last update

func (*StorageNode) SetMeta

func (n *StorageNode) SetMeta(meta string)

SetMeta returns this node name

func (*StorageNode) SetSize

func (n *StorageNode) SetSize(size uint64)

SetSize sets the node size field

func (*StorageNode) Tag

func (n *StorageNode) Tag(tag string)

Tag adds a tag to a storage

func (*StorageNode) Untag

func (n *StorageNode) Untag(tag string)

Untag removes a tag from storage

func (*StorageNode) UpdateStorage

func (n *StorageNode) UpdateStorage(fsPath string, path string, meta string, tags []string)

UpdateStorage updates a storage fields

Jump to

Keyboard shortcuts

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