externaldrive

package
v2.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverID  = "externaldrive"
	TokenType = "externaldrive"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MountDetector

type MountDetector interface {
	// Events returns a channel that emits MountEvent when a removable device is mounted.
	// The channel is closed when Stop() is called.
	Events() <-chan MountEvent

	// Unmounts returns a channel that emits the DeviceID when a removable device is unmounted.
	// The channel is closed when Stop() is called.
	Unmounts() <-chan string

	// Start begins monitoring for mount/unmount events.
	// Returns an error if the platform-specific monitoring service cannot be initialized.
	Start() error

	// Stop terminates the mount detector and releases all resources.
	// After Stop() is called, the Events() and Unmounts() channels are closed.
	Stop()
}

MountDetector provides platform-specific mount event detection for removable storage devices. Implementations must be event-driven (not polling-based) and should filter for removable devices only, excluding internal hard drives and system partitions.

func NewMountDetector

func NewMountDetector() (MountDetector, error)

NewMountDetector creates a new Linux mount detector. It tries D-Bus/UDisks2 first, and falls back to inotify if D-Bus is unavailable.

type MountEvent

type MountEvent struct {
	// DeviceID is a unique and stable identifier for the device, such as a volume UUID
	// or serial number. This is used to track the device across mount/unmount cycles.
	DeviceID string

	// MountPath is the filesystem path where the volume is mounted.
	// Examples: "E:\", "/media/user/USB_DRIVE", "/Volumes/MyUSB"
	MountPath string

	// VolumeLabel is the user-facing volume label for the device.
	// Examples: "MyUSB", "SD_CARD"
	VolumeLabel string

	// DeviceType indicates the type of removable device.
	// Examples: "USB", "SD", "removable"
	DeviceType string
}

MountEvent represents a filesystem mount event for a removable storage device.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader implements the readers.Reader interface for external drive devices.

func NewReader

func NewReader(cfg *config.Instance) *Reader

NewReader creates a new external drive reader instance.

func (*Reader) CancelWrite

func (*Reader) CancelWrite()

func (*Reader) Capabilities

func (*Reader) Capabilities() []readers.Capability

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Connected

func (r *Reader) Connected() bool

func (*Reader) Detect

func (*Reader) Detect(_ []string) string

func (*Reader) Device

func (r *Reader) Device() string

func (*Reader) IDs

func (*Reader) IDs() []string

func (*Reader) Info

func (r *Reader) Info() string

func (*Reader) Metadata

func (*Reader) Metadata() readers.DriverMetadata

func (*Reader) OnMediaChange

func (*Reader) OnMediaChange(*models.ActiveMedia) error

func (*Reader) Open

func (r *Reader) Open(device config.ReadersConnect, iq chan<- readers.Scan) error

func (*Reader) Write

func (*Reader) Write(_ string) (*tokens.Token, error)

Jump to

Keyboard shortcuts

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