Documentation
¶
Overview ¶
Package state manages synchronization state for document tracking.
Index ¶
- Constants
- type ConversionStatus
- type DocumentState
- func (ds *DocumentState) MarkError(err error)
- func (ds *DocumentState) MarkOCRComplete()
- func (ds *DocumentState) MarkSynced(version int, modifiedClient time.Time, localPath, hash string)
- func (ds *DocumentState) NeedsOCR() bool
- func (ds *DocumentState) NeedsSync(remoteVersion int, remoteModified time.Time) bool
- func (ds *DocumentState) SetConversionStatus(status ConversionStatus)
- type Manager
- func (m *Manager) AddDocument(doc *DocumentState)
- func (m *Manager) Count() int
- func (m *Manager) GetDocument(id string) *DocumentState
- func (m *Manager) GetDocumentsByLabel(label string) []*DocumentState
- func (m *Manager) GetDocumentsByStatus(status ConversionStatus) []*DocumentState
- func (m *Manager) GetDocumentsNeedingOCR() []*DocumentState
- func (m *Manager) GetState() *SyncState
- func (m *Manager) Load() error
- func (m *Manager) RemoveDocument(id string)
- func (m *Manager) Reset()
- func (m *Manager) Save() error
- func (m *Manager) UpdateLastSync()
- type SyncState
- func (ss *SyncState) AddDocument(doc *DocumentState)
- func (ss *SyncState) GetDocument(id string) *DocumentState
- func (ss *SyncState) GetDocumentsByLabel(label string) []*DocumentState
- func (ss *SyncState) GetDocumentsByStatus(status ConversionStatus) []*DocumentState
- func (ss *SyncState) GetDocumentsNeedingOCR() []*DocumentState
- func (ss *SyncState) RemoveDocument(id string)
- func (ss *SyncState) UpdateLastSync()
Constants ¶
const StateFileVersion = 1
StateFileVersion is the current version of the state file format
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConversionStatus ¶
type ConversionStatus string
ConversionStatus represents the status of document conversion
const ( // ConversionStatusPending indicates conversion has not been attempted ConversionStatusPending ConversionStatus = "pending" // ConversionStatusInProgress indicates conversion is currently running ConversionStatusInProgress ConversionStatus = "in_progress" // ConversionStatusCompleted indicates conversion completed successfully ConversionStatusCompleted ConversionStatus = "completed" // ConversionStatusFailed indicates conversion failed ConversionStatusFailed ConversionStatus = "failed" // ConversionStatusSkipped indicates conversion was skipped (e.g., already a PDF) ConversionStatusSkipped ConversionStatus = "skipped" )
type DocumentState ¶
type DocumentState struct {
// ID is the document's unique identifier
ID string `json:"id"`
// Name is the document's visible name
Name string `json:"name"`
// Version is the document version number from reMarkable API
Version int `json:"version"`
// ModifiedClient is when the document was last modified on the client
ModifiedClient time.Time `json:"modified_client"`
// LastSynced is when this document was last synced
LastSynced time.Time `json:"last_synced"`
// LocalPath is the path to the local copy of the document
LocalPath string `json:"local_path"`
// Hash is the SHA256 hash of the downloaded content for change detection
Hash string `json:"hash"`
// Type is the document type (DocumentType or CollectionType)
Type string `json:"type"`
// Parent is the ID of the parent collection
Parent string `json:"parent"`
// OCRProcessed indicates if OCR has been performed on this document
OCRProcessed bool `json:"ocr_processed"`
// OCRTimestamp is when OCR was last performed
OCRTimestamp time.Time `json:"ocr_timestamp,omitempty"`
// ConversionStatus is the status of PDF conversion
ConversionStatus ConversionStatus `json:"conversion_status"`
// Error contains any error message from the last sync attempt
Error string `json:"error,omitempty"`
// RetryCount is the number of sync retry attempts
RetryCount int `json:"retry_count"`
// Labels are the reMarkable labels/tags associated with this document
Labels []string `json:"labels,omitempty"`
}
DocumentState represents the sync state for a single document
func NewDocumentState ¶
func NewDocumentState(id, name, docType, parent string) *DocumentState
NewDocumentState creates a new DocumentState for a document
func (*DocumentState) MarkError ¶
func (ds *DocumentState) MarkError(err error)
MarkError records an error during sync
func (*DocumentState) MarkOCRComplete ¶
func (ds *DocumentState) MarkOCRComplete()
MarkOCRComplete updates the document state after successful OCR
func (*DocumentState) MarkSynced ¶
func (ds *DocumentState) MarkSynced(version int, modifiedClient time.Time, localPath, hash string)
MarkSynced updates the document state after a successful sync
func (*DocumentState) NeedsOCR ¶
func (ds *DocumentState) NeedsOCR() bool
NeedsOCR returns true if the document needs OCR processing
func (*DocumentState) NeedsSync ¶
func (ds *DocumentState) NeedsSync(remoteVersion int, remoteModified time.Time) bool
NeedsSync returns true if the document needs to be synced based on version or modification time
func (*DocumentState) SetConversionStatus ¶
func (ds *DocumentState) SetConversionStatus(status ConversionStatus)
SetConversionStatus updates the conversion status
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles sync state persistence and operations
func LoadOrCreate ¶
LoadOrCreate loads an existing state file or creates a new one if it doesn't exist This is a convenience function that combines Load with automatic Save on new state
func (*Manager) AddDocument ¶
func (m *Manager) AddDocument(doc *DocumentState)
AddDocument adds or updates a document in the state
func (*Manager) GetDocument ¶
func (m *Manager) GetDocument(id string) *DocumentState
GetDocument returns the document state for a specific document ID
func (*Manager) GetDocumentsByLabel ¶
func (m *Manager) GetDocumentsByLabel(label string) []*DocumentState
GetDocumentsByLabel returns all documents with a specific label
func (*Manager) GetDocumentsByStatus ¶
func (m *Manager) GetDocumentsByStatus(status ConversionStatus) []*DocumentState
GetDocumentsByStatus returns all documents with a specific conversion status
func (*Manager) GetDocumentsNeedingOCR ¶
func (m *Manager) GetDocumentsNeedingOCR() []*DocumentState
GetDocumentsNeedingOCR returns all documents that need OCR processing
func (*Manager) Load ¶
Load reads the sync state from the JSON file If the file doesn't exist, returns a new empty state (not an error)
func (*Manager) RemoveDocument ¶
RemoveDocument removes a document from the state
func (*Manager) Reset ¶
func (m *Manager) Reset()
Reset clears all state and creates a fresh empty state
func (*Manager) UpdateLastSync ¶
func (m *Manager) UpdateLastSync()
UpdateLastSync updates the last sync timestamp
type SyncState ¶
type SyncState struct {
// LastSync is the timestamp of the last successful sync operation
LastSync time.Time `json:"last_sync"`
// Documents is a map of document ID to their sync state
Documents map[string]*DocumentState `json:"documents"`
// Version is the state file format version
Version int `json:"version"`
}
SyncState represents the overall synchronization state for the application
func (*SyncState) AddDocument ¶
func (ss *SyncState) AddDocument(doc *DocumentState)
AddDocument adds or updates a document in the sync state
func (*SyncState) GetDocument ¶
func (ss *SyncState) GetDocument(id string) *DocumentState
GetDocument returns the DocumentState for a document ID, or nil if not found
func (*SyncState) GetDocumentsByLabel ¶
func (ss *SyncState) GetDocumentsByLabel(label string) []*DocumentState
GetDocumentsByLabel returns all documents with the specified label
func (*SyncState) GetDocumentsByStatus ¶
func (ss *SyncState) GetDocumentsByStatus(status ConversionStatus) []*DocumentState
GetDocumentsByStatus returns all documents with the specified conversion status
func (*SyncState) GetDocumentsNeedingOCR ¶
func (ss *SyncState) GetDocumentsNeedingOCR() []*DocumentState
GetDocumentsNeedingOCR returns all documents that need OCR processing
func (*SyncState) RemoveDocument ¶
RemoveDocument removes a document from the sync state
func (*SyncState) UpdateLastSync ¶
func (ss *SyncState) UpdateLastSync()
UpdateLastSync updates the last sync timestamp