Documentation
¶
Index ¶
- type ChangeEvent
- type CloudTransport
- func (t *CloudTransport) Close() error
- func (t *CloudTransport) Connect() error
- func (t *CloudTransport) DeleteDocument(docID string) error
- func (t *CloudTransport) GetMetadata(docID string) (*model.Metadata, error)
- func (t *CloudTransport) ListDocuments() ([]model.Document, error)
- func (t *CloudTransport) Name() string
- func (t *CloudTransport) ReadFile(docID, path string) (io.ReadCloser, error)
- func (t *CloudTransport) SetMetadata(docID string, m *model.Metadata) error
- func (t *CloudTransport) SyncDoc(docID string) error
- func (t *CloudTransport) WriteFile(docID, path string, r io.Reader) error
- type SSHOption
- type SSHTransport
- func (t *SSHTransport) Close() error
- func (t *SSHTransport) Connect() error
- func (t *SSHTransport) DeleteDocument(docID string) error
- func (t *SSHTransport) GetMetadata(docID string) (*model.Metadata, error)
- func (t *SSHTransport) ListDocuments() ([]model.Document, error)
- func (t *SSHTransport) Name() string
- func (t *SSHTransport) ReadFile(docID, relPath string) (io.ReadCloser, error)
- func (t *SSHTransport) RestartUI() error
- func (t *SSHTransport) RunCommand(cmd string) (string, error)
- func (t *SSHTransport) RunCommandBytes(cmd string) ([]byte, error)
- func (t *SSHTransport) Screenshot() (image.Image, error)
- func (t *SSHTransport) SetMetadata(docID string, m *model.Metadata) error
- func (t *SSHTransport) WatchChanges(ctx context.Context) (<-chan ChangeEvent, error)
- func (t *SSHTransport) WriteFile(docID, relPath string, r io.Reader) error
- func (t *SSHTransport) WriteRawFile(remotePath string, data []byte) error
- type Transport
- type Watchable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeEvent ¶
type ChangeEvent struct {
DocID string
Path string
Type string // "modified", "created", "deleted"
}
ChangeEvent represents a document modification on the device
type CloudTransport ¶
type CloudTransport struct {
// contains filtered or unexported fields
}
CloudTransport implements document access via sync v3
func NewCloudTransport ¶
func NewCloudTransport() *CloudTransport
func (*CloudTransport) Close ¶
func (t *CloudTransport) Close() error
func (*CloudTransport) Connect ¶
func (t *CloudTransport) Connect() error
func (*CloudTransport) DeleteDocument ¶
func (t *CloudTransport) DeleteDocument(docID string) error
DeleteDocument removes a doc from the root index. Note: this is a hard delete (removes from root entirely). The CLI's `rm` command may want to do a soft delete by moving to trash via SetMetadata instead — that's a caller decision.
func (*CloudTransport) GetMetadata ¶
func (t *CloudTransport) GetMetadata(docID string) (*model.Metadata, error)
GetMetadata downloads and parses a doc's .metadata blob
func (*CloudTransport) ListDocuments ¶
func (t *CloudTransport) ListDocuments() ([]model.Document, error)
ListDocuments fetches docs — caches metadata so repeat calls are free. First call fetches root + per-doc index/metadata blobs (each cached on disk by content hash, so subsequent runs only re-fetch the mutable root).
func (*CloudTransport) Name ¶
func (t *CloudTransport) Name() string
func (*CloudTransport) ReadFile ¶
func (t *CloudTransport) ReadFile(docID, path string) (io.ReadCloser, error)
ReadFile downloads a file from the cloud blob tree
func (*CloudTransport) SetMetadata ¶
func (t *CloudTransport) SetMetadata(docID string, m *model.Metadata) error
SetMetadata uploads .metadata blob and updates the doc + root indexes
func (*CloudTransport) SyncDoc ¶
func (t *CloudTransport) SyncDoc(docID string) error
SyncDoc builds the doc index, uploads it, and updates the root index. Retries once on 412 (generation race) by re-fetching root and rebuilding.
type SSHOption ¶
type SSHOption func(*SSHTransport)
SSHOption configures the SSH transport
type SSHTransport ¶
type SSHTransport struct {
// contains filtered or unexported fields
}
SSHTransport implements DeviceTransport via SSH/SFTP
func NewSSHTransport ¶
func NewSSHTransport(opts ...SSHOption) *SSHTransport
NewSSHTransport creates a new SSH transport
func (*SSHTransport) Connect ¶
func (t *SSHTransport) Connect() error
Connect establishes SSH + SFTP connections
func (*SSHTransport) DeleteDocument ¶
func (t *SSHTransport) DeleteDocument(docID string) error
DeleteDocument removes all files for a document
func (*SSHTransport) GetMetadata ¶
func (t *SSHTransport) GetMetadata(docID string) (*model.Metadata, error)
GetMetadata reads a document's .metadata JSON
func (*SSHTransport) ListDocuments ¶
func (t *SSHTransport) ListDocuments() ([]model.Document, error)
ListDocuments reads all metadata in a single SSH command (~1s vs 10s+ for individual SFTP reads)
func (*SSHTransport) Name ¶
func (t *SSHTransport) Name() string
func (*SSHTransport) ReadFile ¶
func (t *SSHTransport) ReadFile(docID, relPath string) (io.ReadCloser, error)
ReadFile reads a file relative to a document's UUID space relPath examples:
"content" -> {xochitl}/{uuid}.content (top-level doc file)
"pdf" -> {xochitl}/{uuid}.pdf
"abc123.rm" -> {xochitl}/{uuid}/abc123.rm (page file inside UUID dir)
"abc/def.json"-> {xochitl}/{uuid}/abc/def.json
func (*SSHTransport) RestartUI ¶
func (t *SSHTransport) RestartUI() error
RestartUI restarts the xochitl service
func (*SSHTransport) RunCommand ¶
func (t *SSHTransport) RunCommand(cmd string) (string, error)
RunCommand executes a command over SSH and returns stdout
func (*SSHTransport) RunCommandBytes ¶
func (t *SSHTransport) RunCommandBytes(cmd string) ([]byte, error)
RunCommandBytes executes a command and returns raw stdout bytes
func (*SSHTransport) Screenshot ¶
func (t *SSHTransport) Screenshot() (image.Image, error)
Screenshot captures the device screen via /proc/PID/mem
func (*SSHTransport) SetMetadata ¶
func (t *SSHTransport) SetMetadata(docID string, m *model.Metadata) error
SetMetadata writes a document's .metadata JSON
func (*SSHTransport) WatchChanges ¶
func (t *SSHTransport) WatchChanges(ctx context.Context) (<-chan ChangeEvent, error)
WatchChanges polls for file changes and emits events
func (*SSHTransport) WriteFile ¶
func (t *SSHTransport) WriteFile(docID, relPath string, r io.Reader) error
WriteFile writes a file into a document's space top-level doc files (content, pdf, epub) → {uuid}.{relPath} page/subdir files (contain / or .rm) → {uuid}/{relPath}
func (*SSHTransport) WriteRawFile ¶
func (t *SSHTransport) WriteRawFile(remotePath string, data []byte) error
WriteRawFile writes arbitrary bytes to an absolute path on the device
type Transport ¶
type Transport interface {
Connect() error
Close() error
Name() string
// documents
ListDocuments() ([]model.Document, error)
ReadFile(docID, path string) (io.ReadCloser, error)
WriteFile(docID, path string, r io.Reader) error
DeleteDocument(docID string) error
// metadata
GetMetadata(docID string) (*model.Metadata, error)
SetMetadata(docID string, m *model.Metadata) error
}
Transport is the single interface for device communication
func AutoDetect ¶
AutoDetect tries SSH first, falls back to cloud