v0.10.0: ports and adapters refactor
- Extract shared manifest types into internal/manifest/types leaf package. - Extract SQLite adapter into internal/manifest/sqlite. - Extract JSONL adapter into internal/manifest/jsonl. - Isolate modernc.org/sqlite import to sqlite/adapter.go. - Add adapter-backed registry with manifest.Default. - Adapter-agnostic ConvertManifest in types/. - MemoryAdapter for in-memory manifest testing. - CLI uses manifest.Default registry directly. - SQLite LogWriter type assertion moved into SQLiteAdapter. - Manifest interface includes Entries(); EntryReader removed. - No behavior changes. 100% coverage across all 6 packages.
This commit is contained in:
@@ -1,51 +1,37 @@
|
||||
package manifest
|
||||
|
||||
import "time"
|
||||
import "gitea.k3s.k0.nu/tools/photocli/internal/manifest/types"
|
||||
|
||||
type Entry struct {
|
||||
ID string
|
||||
Filename string
|
||||
Path string
|
||||
Size int64
|
||||
Cloud string
|
||||
Checksum string
|
||||
Exported int64
|
||||
}
|
||||
type Entry = types.Entry
|
||||
|
||||
type Manifest interface {
|
||||
Has(id string) bool
|
||||
Add(id string, filename string, size int64, cloud string)
|
||||
AddEntry(entry Entry)
|
||||
Save() error
|
||||
Close()
|
||||
OpenAppend() error
|
||||
}
|
||||
type Manifest = types.Manifest
|
||||
|
||||
type EntryReader interface {
|
||||
Entries() map[string]Entry
|
||||
}
|
||||
type EntryReader = types.EntryReader
|
||||
|
||||
func newEntry(id, filename string, size int64, cloud string) Entry {
|
||||
return Entry{
|
||||
ID: id,
|
||||
Filename: filename,
|
||||
Path: filename,
|
||||
Size: size,
|
||||
Cloud: cloud,
|
||||
Exported: time.Now().Unix(),
|
||||
}
|
||||
}
|
||||
type Format = types.Format
|
||||
|
||||
func NewEntry(id, filename, path string, size int64, cloud string) Entry {
|
||||
e := newEntry(id, filename, size, cloud)
|
||||
if path != "" {
|
||||
e.Path = path
|
||||
}
|
||||
return e
|
||||
}
|
||||
const (
|
||||
FormatJSONL = types.FormatJSONL
|
||||
FormatSQLite = types.FormatSQLite
|
||||
)
|
||||
|
||||
func NewEntryWithChecksum(id, filename, path string, size int64, cloud, checksum string) Entry {
|
||||
e := NewEntry(id, filename, path, size, cloud)
|
||||
e.Checksum = checksum
|
||||
return e
|
||||
}
|
||||
type LogEntry = types.LogEntry
|
||||
|
||||
type LogWriter = types.LogWriter
|
||||
|
||||
var NoopLogWriter = types.NoopLogWriter
|
||||
|
||||
type Adapter = types.Adapter
|
||||
|
||||
type Registry = types.Registry
|
||||
|
||||
type FormatReporter = types.FormatReporter
|
||||
|
||||
var (
|
||||
NewRegistry = types.NewRegistry
|
||||
NewEntry = types.NewEntry
|
||||
NewEntryWithChecksum = types.NewEntryWithChecksum
|
||||
LogPath = types.LogPath
|
||||
ConvertManifest = types.ConvertManifest
|
||||
NewFileLogWriter = types.NewFileLogWriter
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user