Documentation
¶
Index ¶
- Variables
- func NormalizeVirtualPath(p string) string
- func QueryStaleCount(mountName string, storageID string) (int64, error)
- func Reset(mountName string) error
- type DB
- func (d *DB) Close() error
- func (d *DB) DirExists(ctx context.Context, storageID string, path string) (bool, error)
- func (d *DB) FinalizeDelete(ctx context.Context, storageID string, p string, isDir bool) error
- func (d *DB) FinalizeRename(ctx context.Context, storageID string, oldPath string, newPath string) error
- func (d *DB) FinalizeSetattr(ctx context.Context, storageID string, p string) error
- func (d *DB) GetEffectiveFile(ctx context.Context, storageID string, path string) (File, bool, error)
- func (d *DB) ListDirEntries(ctx context.Context, storageID string, dirPath string) ([]DirEntry, bool, error)
- func (d *DB) MarkDeleted(ctx context.Context, storageID string, p string, isDir bool) (bool, error)
- func (d *DB) Ping(ctx context.Context) error
- func (d *DB) RenamePath(ctx context.Context, storageID string, oldPath string, newPath string) (bool, error)
- func (d *DB) SQL() *sql.DB
- func (d *DB) UpsertFile(ctx context.Context, storageID string, p string, isDir bool, sizeBytes *int64, ...) error
- func (d *DB) UpsertMeta(ctx context.Context, storageID string, p string, mode *uint32, uid *uint32, ...) (bool, error)
- type DirEntry
- type File
- type IndexerStateRow
- type InspectFileRow
- type VirtualChildEntry
Constants ¶
This section is empty.
Variables ¶
var ( // ErrIndexDBSchemaIncompatible is returned when the index db schema is incompatible. ErrIndexDBSchemaIncompatible = errkind.SentinelError("index db schema is incompatible") )
Functions ¶
func NormalizeVirtualPath ¶
NormalizeVirtualPath converts a user-provided virtual path into a stable DB key. It removes leading slashes, cleans dot segments, and returns "" for root.
func QueryStaleCount ¶
QueryStaleCount returns the number of stale (deleted=2) files for a storage. Returns 0 if the DB file does not exist.
Types ¶
type DB ¶
DB provides access to the per-mount index database.
func (*DB) Close ¶
Close checkpoints the WAL and closes the underlying SQL database.
TRUNCATE checkpoint flushes all committed WAL frames to the main DB file and resets the WAL to zero length. This ensures cross-process visibility in environments where WAL-index (SHM) mmap sharing is unreliable (e.g. Docker with VirtioFS bind mounts).
func (*DB) FinalizeDelete ¶
FinalizeDelete removes rows that were previously marked deleted=1 after physical deletion succeeded.
func (*DB) FinalizeRename ¶
func (d *DB) FinalizeRename(ctx context.Context, storageID string, oldPath string, newPath string) error
FinalizeRename updates real_path to match the new on-disk location after physical rename succeeded.
It also ensures virtual paths (path/parent_dir/name) are at their new values. This is normally a no-op because RenamePath already set them during the FUSE operation, but acts as a safety net when the daemon's WAL commit is not yet visible to the prune process (e.g. cross-process WAL visibility lag on overlayfs).
func (*DB) FinalizeSetattr ¶
FinalizeSetattr clears file_meta overrides after they have been applied physically.
func (*DB) GetEffectiveFile ¶
func (d *DB) GetEffectiveFile(ctx context.Context, storageID string, path string) (File, bool, error)
GetEffectiveFile returns a row merged with any file_meta overrides.
func (*DB) ListDirEntries ¶
func (d *DB) ListDirEntries(ctx context.Context, storageID string, dirPath string) ([]DirEntry, bool, error)
ListDirEntries lists immediate children under a directory path, including subdirectories.
func (*DB) MarkDeleted ¶
MarkDeleted soft-deletes a file or directory (optionally its subtree) by setting deleted=1. It enforces POSIX-ish semantics from the mounted view (ENOENT/ENOTEMPTY/ENOTDIR/EISDIR).
func (*DB) RenamePath ¶
func (d *DB) RenamePath(ctx context.Context, storageID string, oldPath string, newPath string) (bool, error)
RenamePath updates virtual paths in the DB and records a pending physical rename by keeping real_path. It supports directory renames by rewriting the subtree.
func (*DB) UpsertFile ¶
func (d *DB) UpsertFile(ctx context.Context, storageID string, p string, isDir bool, sizeBytes *int64, mtimeSec int64, mode uint32, uid uint32, gid uint32) error
UpsertFile upserts a file/dir entry while preserving last_seen_run_id for existing rows.
For new rows, it sets last_seen_run_id to the current indexer_state.current_run_id when available. It never resurrects deleted=1 tombstones; such conflicts are returned as syscall.EBUSY. It also ensures all parent directories exist as is_dir entries so the file becomes visible immediately via DB-backed lookup/readdir.
func (*DB) UpsertMeta ¶
func (d *DB) UpsertMeta(ctx context.Context, storageID string, p string, mode *uint32, uid *uint32, gid *uint32, mtimeSec *int64) (bool, error)
UpsertMeta writes file_meta overrides for SETATTR without touching the physical filesystem. Any nil field is treated as "no change".
type File ¶
type File struct {
StorageID string
Path string
RealPath string
IsDir bool
Size int64
MTimeSec int64
Mode uint32
UID uint32
GID uint32
}
File describes one indexed filesystem entry.
type IndexerStateRow ¶
type IndexerStateRow struct {
StorageID string
CurrentRunID int64
LastCompleted *int64 // unix timestamp, nil if never completed
LastDurationMS *int64
FileCount *int64
TotalBytes *int64
}
IndexerStateRow holds summary stats from the indexer_state table.
func QueryIndexerState ¶
func QueryIndexerState(mountName string, storageID string) (*IndexerStateRow, error)
QueryIndexerState opens the index DB read-only and returns indexer_state for a storage. Returns nil (no error) if the DB file does not exist or the storage has no row.
type InspectFileRow ¶
type InspectFileRow struct {
StorageID string
Path string
RealPath string
IsDir bool
Size *int64
MTimeSec int64
Mode uint32
UID uint32
GID uint32
Deleted int // 0=live, 1=pending-delete, 2=stale
LastSeenRunID *int64 // which indexer run last saw this entry
// file_meta overrides (nil = no override active).
MetaMTime *int64
MetaMode *uint32
MetaUID *uint32
MetaGID *uint32
// From indexer_state (for correlating last_seen_run_id).
CurrentRunID int64
LastCompleted *int64 // unix timestamp of last completed index run
}
InspectFileRow holds raw and meta-overlay data for one file entry. Unlike GetEffectiveFile, it does NOT filter by deleted status and searches across all storages for a given path.
func QueryFileInspect ¶
func QueryFileInspect(mountName string, path string) ([]InspectFileRow, error)
QueryFileInspect opens the index DB read-only and returns all rows matching the given path across ALL storages, regardless of deleted status. It joins file_meta for overrides and indexer_state for run correlation. Returns nil (no error) if the DB file does not exist.
type VirtualChildEntry ¶
VirtualChildEntry describes one virtual directory child entry.
func QueryVirtualChildren ¶
func QueryVirtualChildren(mountName string, dirPath string, namePrefix string, limit int) ([]VirtualChildEntry, error)
QueryVirtualChildren lists distinct child entries under dirPath across all storages. Returns nil (no error) if the DB file does not exist.