feat(metadata): SQLite backend, storage reconciliation and local defaults
- pluggable per-domain Repository interfaces; PostgreSQL and SQLite impls - SQLite on modernc.org/sqlite (WAL, busy_timeout, foreign_keys, immediate tx) - separate migrations/sqlite and db.MigrateSQLite; store.NewPostgres/NewSQLite - cmd/reconcile compares object storage with the journal (report, then --delete) - storage.Backend.List and photos.Repository.AllStorageKeys - DB_BACKEND/SQLITE_PATH and STORAGE_BACKEND/FS_ROOT selectable; local defaults (sqlite ./galo.db, fs ./data) - Makefile reconcile/reconcile-delete; docs and .env.example updated
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package photos
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"shared-album/internal/models"
|
||||
)
|
||||
|
||||
// Repository is the persistence contract for the photos domain, including the
|
||||
// object ledger, variant queue and garbage collection.
|
||||
type Repository interface {
|
||||
CreateWithOriginal(ctx context.Context, p *models.Photo, obj *Object) error
|
||||
DeleteUpload(ctx context.Context, photoID, objectID string) error
|
||||
GetByID(ctx context.Context, id, viewerID string) (*models.Photo, error)
|
||||
List(ctx context.Context, in ListParams) ([]models.Photo, error)
|
||||
SetDeleted(ctx context.Context, id string, deleted bool) error
|
||||
UpdateAlbum(ctx context.Context, id, albumID string) error
|
||||
Clone(ctx context.Context, src *models.Photo, albumID, uploaderID, id string) error
|
||||
HardDelete(ctx context.Context, id string) error
|
||||
ListTrash(ctx context.Context, userID string) ([]models.Photo, error)
|
||||
TrashCount(ctx context.Context, userID string) (int, error)
|
||||
RestoreToAlbum(ctx context.Context, id, albumID string) error
|
||||
AlbumExists(ctx context.Context, albumID string) (bool, error)
|
||||
ListTags(ctx context.Context, userID, q string) ([]models.Tag, error)
|
||||
EnsureTag(ctx context.Context, userID, name string) (*models.Tag, error)
|
||||
AttachTag(ctx context.Context, photoID, tagID string) error
|
||||
DetachTag(ctx context.Context, photoID, tagID string) error
|
||||
TagOwnedBy(ctx context.Context, tagID, userID string) (bool, error)
|
||||
SetCoverIfEmpty(ctx context.Context, albumID, photoID string)
|
||||
UpdateFilename(ctx context.Context, id, filename string) error
|
||||
BackfillEXIF(ctx context.Context, fetch func(context.Context, string) ([]byte, error)) (int, error)
|
||||
|
||||
CreateObject(ctx context.Context, o *Object) error
|
||||
SetObjectState(ctx context.Context, id, state string) error
|
||||
ActivateObject(ctx context.Context, id string) error
|
||||
MarkObjectDeleting(ctx context.Context, id string) error
|
||||
DeleteObjectRow(ctx context.Context, id string) error
|
||||
BindObject(ctx context.Context, photoID, objectID, role string) error
|
||||
PhotoObjectIDs(ctx context.Context, photoID string) ([]string, error)
|
||||
ObjectRefCount(ctx context.Context, objectID string) (int, error)
|
||||
OriginalObject(ctx context.Context, photoID string) (*Object, error)
|
||||
PhotosByOriginalObject(ctx context.Context, originalObjectID string) ([]string, error)
|
||||
ClaimGarbage(ctx context.Context, limit int) ([]Object, error)
|
||||
ClaimStalePending(ctx context.Context, olderThan time.Duration, limit int) ([]Object, error)
|
||||
ClaimVariantJobs(ctx context.Context, limit int, lease time.Duration) ([]string, error)
|
||||
CompleteVariantJob(ctx context.Context, photoID string) error
|
||||
FailVariantJob(ctx context.Context, photoID, errMsg string, maxAttempts int) error
|
||||
|
||||
// AllStorageKeys returns every key registered in the object journal.
|
||||
AllStorageKeys(ctx context.Context) ([]string, error)
|
||||
}
|
||||
Reference in New Issue
Block a user