Documentation
¶
Index ¶
- Constants
- func DeriveStorageID(name string) int
- func IsDir(n Node) bool
- func IsModeDir(n Node) bool
- func IsStorage(n Node) bool
- func MayHaveChildren(n Node) bool
- func ShouldDescendForRecSize(n Node) bool
- type FileNode
- func (n *FileNode) AddChild(child *FileNode)
- func (n *FileNode) GetAttr(rawSize bool, long bool) map[string]string
- func (n *FileNode) GetDirectChildren() map[string]*FileNode
- func (n *FileNode) GetMAccess() int64
- func (n *FileNode) GetMode() string
- func (n *FileNode) GetName() string
- func (n *FileNode) GetPath() string
- func (n *FileNode) GetSize() uint64
- func (n *FileNode) GetSortedDirectChildren() []*FileNode
- func (n *FileNode) GetType() FileType
- func (n *FileNode) IsExec() bool
- func (n *FileNode) RemoveChild(removeMe Node)
- func (n *FileNode) Seen() bool
- func (n *FileNode) SetSize(size uint64)
- func (n *FileNode) Update(info fs.FileInfo)
- type FileType
- type Node
- type StorageNode
- func (n *StorageNode) AddChild(child *FileNode)
- func (n *StorageNode) GetAttr(rawSize bool, long bool) map[string]string
- func (n *StorageNode) GetDirectChildren() map[string]*FileNode
- func (n *StorageNode) GetMAccess() int64
- func (n *StorageNode) GetMode() string
- func (n *StorageNode) GetName() string
- func (n *StorageNode) GetPath() string
- func (n *StorageNode) GetSize() uint64
- func (n *StorageNode) GetSortedDirectChildren() []*FileNode
- func (n *StorageNode) GetType() FileType
- func (n *StorageNode) IsDir() bool
- func (n *StorageNode) RecursiveFillSize()
- func (n *StorageNode) RemoveChild(removeMe Node)
- func (n *StorageNode) Seen() bool
- func (n *StorageNode) SetMeta(meta string)
- func (n *StorageNode) SetSize(size uint64)
- func (n *StorageNode) Tag(tag string)
- func (n *StorageNode) Untag(tag string)
- func (n *StorageNode) UpdateStorage(fsPath string, path string, meta string, tags []string)
Constants ¶
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 ¶
DeriveStorageID derive id from storage name
func MayHaveChildren ¶
MayHaveChildren returns true if the node may have children
func ShouldDescendForRecSize ¶
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 ¶
NewFileNode creates a new file node
func (*FileNode) GetDirectChildren ¶
GetDirectChildren returns this node children
func (*FileNode) GetMAccess ¶
GetMAccess returns node modification date
func (*FileNode) GetSortedDirectChildren ¶
GetSortedDirectChildren returns children sorted by names
func (*FileNode) RemoveChild ¶
RemoveChild removes a child from this node
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) GetPath ¶
func (n *StorageNode) GetPath() string
GetPath returns the node relative path
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) 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) 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