Extract a FileStore interface from the concrete *storage.Storage MinIO wrapper so the API layer is storage-backend agnostic. - Define FileStore interface in internal/storage/interface.go - Add Exists method to MinIO Storage (via StatObject) - Add compile-time interface satisfaction check - Change Server.storage and ServerState.storage to FileStore interface - Update NewServer and NewServerState signatures - Add Backend and FilesystemConfig fields to StorageConfig - Add backend selection switch in main.go (minio/filesystem/unknown) - Update config.example.yaml with backend field The nil-interface pattern is preserved: when storage is unconfigured, store remains a true nil FileStore (not a typed nil pointer), so all existing if s.storage == nil checks continue to work correctly. Closes #126
22 lines
762 B
Go
22 lines
762 B
Go
// Package storage defines the FileStore interface and backend implementations.
|
|
package storage
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"net/url"
|
|
"time"
|
|
)
|
|
|
|
// FileStore is the interface for file storage backends.
|
|
type FileStore interface {
|
|
Put(ctx context.Context, key string, reader io.Reader, size int64, contentType string) (*PutResult, error)
|
|
Get(ctx context.Context, key string) (io.ReadCloser, error)
|
|
GetVersion(ctx context.Context, key string, versionID string) (io.ReadCloser, error)
|
|
Delete(ctx context.Context, key string) error
|
|
Exists(ctx context.Context, key string) (bool, error)
|
|
Copy(ctx context.Context, srcKey, dstKey string) error
|
|
PresignPut(ctx context.Context, key string, expiry time.Duration) (*url.URL, error)
|
|
Ping(ctx context.Context) error
|
|
}
|