Documentation
¶
Index ¶
- func ComputeZipHash(zipPath string) (string, error)
- func ContentsDir(sessionID string) (string, error)
- func CreateWorkspace(session *Session, dirName string) error
- func DataDir() (string, error)
- func DeleteFile(contentsDir, relativePath string, recursive bool) error
- func DeleteSession(id string) error
- func Extract(zipPath, destDir string, limits security.Limits) (int, uint64, error)
- func LockPath(sessionID string) (string, error)
- func MetadataPath(sessionID string) (string, error)
- func OriginalZipPath(sessionID string) (string, error)
- func ReadFile(contentsDir, relativePath string) ([]byte, error)
- func RemoveWorkspace(session *Session, dirName string) error
- func Repack(contentsDir, destZipPath string) error
- func RotateBackups(sourcePath string, maxDepth int) (string, error)
- func TouchSession(session *Session) error
- func TreeView(contentsDir, relativePath string, maxDepth int) (string, int, int, error)
- func UpdateSession(session *Session, dirName string) error
- func WorkspaceDir(sessionID string) (string, error)
- func WorkspacesDir() (string, error)
- func WriteFile(contentsDir, relativePath string, content []byte, createDirs bool) error
- type Config
- type DefaultsConfig
- type FileEntry
- type GrepMatch
- type Lock
- type SecurityConfig
- type Session
- type StatusResult
- type SyncResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeZipHash ¶
ComputeZipHash computes the SHA-256 hash of a zip file.
func ContentsDir ¶
ContentsDir returns the contents/ directory within a session workspace.
func CreateWorkspace ¶
CreateWorkspace creates the directory structure for a session workspace.
func DataDir ¶
DataDir returns the base data directory for zipfs. It follows the XDG Base Directory Specification: - $ZIPFS_DATA_DIR (full override) - $XDG_DATA_HOME/zipfs - ~/.local/share/zipfs (fallback)
func DeleteFile ¶
DeleteFile deletes a file or directory from the workspace.
func Extract ¶
Extract extracts a zip file to the destination directory. Returns the number of files extracted and the total size in bytes. Uses fail-closed security validation - any single invalid path aborts the entire extraction.
func MetadataPath ¶
MetadataPath returns the path to the metadata.json file for a session.
func OriginalZipPath ¶
OriginalZipPath returns the path to the original.zip file for a session.
func RemoveWorkspace ¶
RemoveWorkspace removes the entire workspace directory for a session.
func Repack ¶
Repack creates a zip file from the contents of a directory. Does NOT follow symlinks for security.
func RotateBackups ¶
RotateBackups rotates backup files for a source zip. Returns the path to the new backup file.
func TouchSession ¶
TouchSession updates the last_accessed_at timestamp.
func UpdateSession ¶
UpdateSession writes the session metadata to disk.
func WorkspaceDir ¶
WorkspaceDir returns the directory for a specific session workspace.
func WorkspacesDir ¶
WorkspacesDir returns the directory containing all session workspaces.
Types ¶
type Config ¶
type Config struct {
Security SecurityConfig `json:"security"`
Defaults DefaultsConfig `json:"defaults"`
}
Config holds global configuration for zipfs.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default configuration as specified in ADR-002.
func LoadConfig ¶
LoadConfig loads configuration from config.json in the data directory. Falls back to default configuration if config.json doesn't exist. Environment variables override both file and default values.
func (*Config) ToSecurityLimits ¶
ToSecurityLimits converts the config to security.Limits for use with security package.
type DefaultsConfig ¶
type DefaultsConfig struct {
BackupRotationDepth int `json:"backup_rotation_depth"`
}
DefaultsConfig holds default values for operations.
type FileEntry ¶
type FileEntry struct {
Name string `json:"name"`
Type string `json:"type"` // "file" or "dir"
SizeBytes uint64 `json:"size_bytes"`
ModifiedAt int64 `json:"modified_at"` // Unix timestamp
}
FileEntry represents a file or directory entry.
type GrepMatch ¶
type GrepMatch struct {
File string `json:"file"`
LineContent string `json:"line_content"`
LineNumber int `json:"line_number"`
}
GrepMatch represents a grep search result.
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock represents a file-based lock using flock.
func AcquireExclusive ¶
AcquireExclusive acquires an exclusive lock on the given path. Only one exclusive lock can be held, and it blocks all shared locks. Blocks until the lock is acquired or timeout is reached.
func AcquireShared ¶
AcquireShared acquires a shared lock on the given path. Multiple shared locks can be held simultaneously. Blocks until the lock is acquired or timeout is reached.
type SecurityConfig ¶
type SecurityConfig struct {
MaxExtractedSizeBytes uint64 `json:"max_extracted_size_bytes"`
MaxFileCount int `json:"max_file_count"`
MaxCompressionRatio float64 `json:"max_compression_ratio"`
MaxTotalDiskBytes uint64 `json:"max_total_disk_bytes"`
MaxSessions int `json:"max_sessions"`
AllowSymlinks bool `json:"allow_symlinks"`
RegexTimeoutMS int `json:"regex_timeout_ms"`
}
SecurityConfig holds security limits and constraints.
type Session ¶
type Session struct {
ID string `json:"id"`
Name string `json:"name"`
SourcePath string `json:"source_path"`
CreatedAt time.Time `json:"created_at"`
LastSyncedAt *time.Time `json:"last_synced_at"`
LastAccessedAt time.Time `json:"last_accessed_at"`
State string `json:"state"` // "open", "syncing"
ZipHashSHA256 string `json:"zip_hash_sha256"`
ExtractedSizeBytes uint64 `json:"extracted_size_bytes"`
FileCount int `json:"file_count"`
}
Session represents a zipfs session with metadata.
func CreateSession ¶
CreateSession creates a new session for the given zip file. This implements the "open" workflow from ADR-003.
func GetSession ¶
GetSession retrieves a session by name, UUID, or UUID prefix.
func ListSessions ¶
ListSessions returns all active sessions.
func ResolveSession ¶
ResolveSession implements auto-resolution logic from ADR-003. Returns the session if exactly one exists, otherwise returns an error.
type StatusResult ¶
type StatusResult struct {
Modified []string `json:"modified"`
Added []string `json:"added"`
Deleted []string `json:"deleted"`
UnchangedCount int `json:"unchanged_count"`
}
StatusResult represents the result of a status check.
func Status ¶
func Status(session *Session) (*StatusResult, error)
Status compares the current workspace contents with the original zip.