fix(17-02): fix cover art replace and remove
Three issues fixed:
1. asBytes() helper for []interface{} → []byte conversion — same
float64 deserialization issue as numeric fields. Cover art data
from the frontend arrives as []interface{} of float64, not []byte.
2. DB sync for cover art — was a placeholder no-op. Now saves image
to covers cache dir (content-hash dedup + thumbnail generation),
upserts cover_art row, and updates release_groups.cover_art_id.
Clear sets cover_art_id to NULL on linked release groups.
3. Frontend ReadFile returns base64 string (Go []byte JSON encoding),
not number[]. Decode with atob() before creating Uint8Array for
preview blob URL.
This commit is contained in:
@@ -73,6 +73,36 @@ func asInt(v any) (int, bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// asBytes extracts a byte slice from a TagChanges value. JSON arrays
|
||||
// from Wails arrive as []interface{} of float64; Go callers may pass
|
||||
// []byte directly. Returns (data, true) on success or (nil, false).
|
||||
func asBytes(v any) ([]byte, bool) {
|
||||
if v == nil {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
if b, ok := v.([]byte); ok {
|
||||
return b, true
|
||||
}
|
||||
|
||||
arr, ok := v.([]interface{})
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
out := make([]byte, len(arr))
|
||||
for i, elem := range arr {
|
||||
f, ok := elem.(float64)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
out[i] = byte(f)
|
||||
}
|
||||
|
||||
return out, true
|
||||
}
|
||||
|
||||
// detectMIME returns the MIME type of image data by checking magic bytes.
|
||||
func detectMIME(data []byte) string {
|
||||
if len(data) >= 2 && data[0] == 0xFF && data[1] == 0xD8 {
|
||||
|
||||
Reference in New Issue
Block a user