Skip to content

FUSE: Create MountManager core infrastructure #9

@efimsky

Description

@efimsky

Parent Issue

Part of #118 (FUSE-based Archive & Remote Browsing Feature)

Summary

Create tnc/mount.py with MountManager class containing core infrastructure for FUSE-based mounting.

Tasks

Data Structures

  • Create ToolAvailability dataclass to track available tools
  • Create MountInfo dataclass to store mount information
  • Create MountResult dataclass for mount operation results

MountManager Class

  • Define MOUNT_BASE = Path('/tmp/tnc-mounts')
  • Define ARCHIVE_EXTENSIONS set with supported formats
  • Implement __init__() that calls _detect_tools() and _cleanup_stale_mounts()
  • Implement _detect_tools() using shutil.which() for each tool
  • Implement is_archive(path) to check if path is supported archive format
  • Implement _generate_mount_hash(source) for unique mount point naming
  • Implement can_mount_archive() to check if archivemount or fuse-archive available

Data Structures Detail

@dataclass
class ToolAvailability:
    archivemount: bool = False
    fuse_archive: bool = False
    sshfs: bool = False
    rclone: bool = False
    p7zip: bool = False
    unrar: bool = False

@dataclass
class MountInfo:
    mount_point: Path
    source: str
    mount_type: str  # 'archive', 'sftp', 'rclone'
    timestamp: float

@dataclass  
class MountResult:
    success: bool
    mount_point: Path | None = None
    error: str = ''

Archive Extensions

ARCHIVE_EXTENSIONS = {
    '.tar.gz', '.tar.bz2', '.tar.xz', '.tgz', '.tbz2', '.txz',
    '.zip', '.7z', '.rar',
}

Testing

  • Test ToolAvailability defaults to all False
  • Test MountInfo stores values correctly
  • Test tool detection with mocked shutil.which()
  • Test is_archive() for all supported extensions
  • Test is_archive() returns False for non-archives
  • Test _generate_mount_hash() generates consistent, filesystem-safe hashes
  • Test can_mount_archive() returns True when archivemount or fuse-archive available

Files

  • Create: tnc/mount.py
  • Create: tests/test_mount.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions