index

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNodeNotFound is returned when a node is not found in the index.
	ErrNodeNotFound = fs.ErrNotExist
)

Functions

This section is empty.

Types

type Manager

type Manager interface {
	// CreateNode creates a new node in the index.
	CreateNode(node *Node) error

	// GetNode retrieves a node by its unique ID.
	GetNode(nodeID string) (*Node, error)

	// GetNodeByPath retrieves a node by its full path.
	GetNodeByPath(path string) (*Node, error)

	// UpdateNode updates an existing node's data.
	// This is used for operations like chmod, chown, or rename.
	UpdateNode(node *Node) error

	// DeleteNode removes a node from the index.
	// It should fail if trying to delete a non-empty directory.
	DeleteNode(nodeID string) error

	// ListChildren retrieves all immediate children of a directory node.
	ListChildren(parentID string) ([]*Node, error)

	// MoveNode moves a node to a new parent directory and/or new name.
	MoveNode(nodeID string, newParentID string, newName string) error
}

Manager defines the interface for managing the file system's namespace and structure.

type Node

type Node struct {
	NodeID   string      // Unique identifier for this node (e.g., a UUID). This is the primary key.
	ParentID string      // NodeID of the parent directory. The root directory's ParentID can be itself or a special value.
	Name     string      // Name of the node within its parent directory (e.g., "document.txt", "images").
	NodeType NodeType    // Type of the node (e.g., File, Directory, Symlink).
	Mode     fs.FileMode // Permissions and mode bits.
	OwnerID  string      // User ID of the owner.
	GroupID  string      // Group ID of the owner.
	Atime    time.Time   // Last access time.
	Mtime    time.Time   // Last modification time of the node itself (e.g., rename, permission change).
	Ctime    time.Time   // Creation time of the node.

	// For NodeType = File:
	// MetaHash is the hash/ID of the FileMeta object in the Meta Store.
	// This links the index entry to the file's content and detailed metadata.
	MetaHash string `json:"meta_hash,omitempty"`

	// For NodeType = Symlink:
	Target string `json:"target,omitempty"` // The path the symbolic link points to.
}

Node represents a single entry in the file system index. It can be a file, a directory, or other types like a symlink.

type NodeType

type NodeType int
const (
	File      NodeType = iota // A regular file.
	Directory                 // A directory.
	Symlink                   // A symbolic link.
)

Jump to

Keyboard shortcuts

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