duplicate

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateFileMD5

func CalculateFileMD5(filePath string) (string, error)

CalculateFileMD5 computes the MD5 hash of a file

func CalculateStreamMD5

func CalculateStreamMD5(r io.Reader) (string, error)

CalculateStreamMD5 computes the MD5 hash from a reader

func DefaultCachePath

func DefaultCachePath() string

DefaultCachePath returns the default cache database path

Types

type Checker

type Checker interface {
	// Check looks for an existing upload by file hash
	Check(ctx context.Context, filePath string) (*Upload, error)

	// Record saves an upload to the cache
	Record(upload *Upload) error
}

Checker provides duplicate detection functionality

type FileInfo

type FileInfo struct {
	Path     string
	MD5      string
	Size     int64
	Filename string
}

FileInfo contains file metadata used for duplicate detection

func GetFileInfo

func GetFileInfo(filePath string) (*FileInfo, error)

GetFileInfo retrieves file information including MD5 hash

type RemoteChecker

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

RemoteChecker implements duplicate checking with local cache only

func NewRemoteChecker

func NewRemoteChecker(cache *SQLiteCache, service string) *RemoteChecker

NewRemoteChecker creates a new checker with cache

func SetupFlickrDuplicateChecker

func SetupFlickrDuplicateChecker(cfg *config.FlickrConfig) (*RemoteChecker, error)

SetupFlickrDuplicateChecker creates a duplicate checker for Flickr (local cache only)

func SetupSmugMugDuplicateChecker

func SetupSmugMugDuplicateChecker(cfg *config.SmugMugConfig) (*RemoteChecker, error)

SetupSmugMugDuplicateChecker creates a duplicate checker for SmugMug (local cache only)

func (*RemoteChecker) Check

func (r *RemoteChecker) Check(ctx context.Context, filePath string) (*Upload, error)

Check looks for an existing upload in the local cache only

func (*RemoteChecker) Close

func (r *RemoteChecker) Close() error

Close closes the underlying cache connection

func (*RemoteChecker) Record

func (r *RemoteChecker) Record(upload *Upload) error

Record saves an upload to the cache

func (*RemoteChecker) SetService

func (r *RemoteChecker) SetService(service string)

SetService changes the active service

type SQLiteCache

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

SQLiteCache implements local duplicate checking via SQLite

func NewSQLiteCache

func NewSQLiteCache(dbPath string) (*SQLiteCache, error)

NewSQLiteCache creates a new SQLite-based cache

func (*SQLiteCache) Check

func (c *SQLiteCache) Check(ctx context.Context, md5Hash string) (*Upload, error)

Check looks up a file by MD5 hash

func (*SQLiteCache) Close

func (c *SQLiteCache) Close() error

Close closes the database connection

func (*SQLiteCache) FindByFilename

func (c *SQLiteCache) FindByFilename(ctx context.Context, filename string) ([]*Upload, error)

FindByFilename searches for uploads with matching filename

func (*SQLiteCache) FindByRemoteID

func (c *SQLiteCache) FindByRemoteID(ctx context.Context, service, remoteID string) (*Upload, error)

FindByRemoteID looks up an upload by service and remote ID

func (*SQLiteCache) GetThumbnail added in v0.8.0

func (c *SQLiteCache) GetThumbnail(ctx context.Context, md5Hash string) (*Thumbnail, error)

GetThumbnail retrieves a cached thumbnail by MD5 hash

func (*SQLiteCache) Record

func (c *SQLiteCache) Record(upload *Upload) error

Record saves an upload to the cache

func (*SQLiteCache) SaveThumbnail added in v0.8.0

func (c *SQLiteCache) SaveThumbnail(thumb *Thumbnail) error

SaveThumbnail stores a thumbnail in the cache

type Thumbnail added in v0.8.0

type Thumbnail struct {
	FileMD5       string
	ThumbnailData string // base64 encoded
	Width         int
	Height        int
	FileSize      int64
	CreatedAt     time.Time
}

Thumbnail represents a cached thumbnail

type Upload

type Upload struct {
	FileMD5    string
	Service    string
	RemoteID   string
	RemoteURL  string
	ImageURL   string
	UploadTime time.Time
	Filename   string
	FileSize   int64
}

Upload represents a cached upload record

Jump to

Keyboard shortcuts

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