package biz

import (
	"context"
	"time"
)

type UploadSession struct {
	ID                  uint
	UserID              uint
	FileName, FileHash  string
	FileSize, ChunkSize int64
	ChunkTotal          int
	Status, StorageKey  string
	MediaID             uint
}

type UploadChunk struct {
	Index int
	Hash  string
	Size  int64
}

type UploadRepo interface {
	FindCompletedSession(context.Context, uint, string) (*UploadSession, error)
	FindUploadingSession(context.Context, uint, string) (*UploadSession, error)
	CreateUploadSession(context.Context, *UploadSession) error
	FindUploadSession(context.Context, uint) (*UploadSession, error)
	ClaimUploadSession(context.Context, uint) (bool, error)
	FailUploadSession(context.Context, uint) error
	CompleteUploadSession(context.Context, uint, string, uint) error
	DeleteUploadSession(context.Context, uint) error
	UpsertChunk(context.Context, uint, *UploadChunk) error
	ListChunks(context.Context, uint) ([]*UploadChunk, error)
	DeleteChunks(context.Context, uint) error
	StaleUploadSessionIDs(context.Context, time.Time) ([]uint, error)
	DeleteUploadData(context.Context, uint) error
}
