gdrive

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MimeGoogleDoc    = "application/vnd.google-apps.document"
	MimeGoogleSheet  = "application/vnd.google-apps.spreadsheet"
	MimeGoogleSlide  = "application/vnd.google-apps.presentation"
	MimePDF          = "application/pdf"
	MimeMSWord       = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
	MimeMSExcel      = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
	MimeMSPowerPoint = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
	MimeMarkdown     = "text/markdown"
	MimePlain        = "text/plain"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GDriveWorker

type GDriveWorker struct {
	DryRun bool
	// contains filtered or unexported fields
}

GDriveWorker implements the worker interface for Google Drive synchronization.

func NewWorker

func NewWorker(cfg *config.Config, db *sql.DB, g GogClient) *GDriveWorker

NewWorker creates a new GDriveWorker instance.

func (*GDriveWorker) ExtractContent

func (w *GDriveWorker) ExtractContent(ctx context.Context, file *db.File) (string, error)

ExtractContent retrieves the content of a Google Drive file and returns it as Markdown.

func (*GDriveWorker) Name

func (w *GDriveWorker) Name() string

Name returns the worker name.

func (*GDriveWorker) SetDryRun

func (w *GDriveWorker) SetDryRun(dryRun bool)

SetDryRun sets the dry-run mode for the worker.

func (*GDriveWorker) Start

func (w *GDriveWorker) Start(ctx context.Context) error

Start begins the synchronization loop. It performs an initial sync and then schedules periodic syncs based on the configuration.

func (*GDriveWorker) Stop

func (w *GDriveWorker) Stop() error

Stop gracefully shuts down the worker.

func (*GDriveWorker) Sync

func (w *GDriveWorker) Sync(ctx context.Context) error

Sync performs the full synchronization process of Google Drive metadata to SQLite, and pulls back enrichment data from Google Sheets.

type GogClient

type GogClient interface {
	DriveLs(ctx context.Context, parentID string) ([]gog.File, error)
	DriveSearch(ctx context.Context, query string) ([]gog.File, error)
	SheetsGetValues(ctx context.Context, sheetID string, cellRange string) ([][]string, error)
	SheetsUpdate(ctx context.Context, sheetID string, cellRange string, values [][]string) error
	SheetsAppend(ctx context.Context, sheetID string, cellRange string, values [][]string) error
	DocsCat(ctx context.Context, fileID string) (string, error)
	SheetsGet(ctx context.Context, sheetID string) (string, error)
	SheetsMetadata(ctx context.Context, sheetID string) (*gog.SpreadsheetMetadata, error)
	DriveDownload(ctx context.Context, fileID string, format string) ([]byte, error)
	DriveDownloadToFile(ctx context.Context, fileID string, format string, outputPath string) error
}

GogClient defines the interface for Google Drive operations needed by the worker.

type OCRClient

type OCRClient interface {
	SetImage(path string) error
	Text() (string, error)
	Close() error
}

OCRClient defines the interface for OCR operations.

Jump to

Keyboard shortcuts

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