mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-04 09:10:48 +02:00
perf(library): resume and parallelize SAF indexing
This commit is contained in:
@@ -373,6 +373,15 @@ func saveLibraryCoverDataToCache(cacheDir, cacheKey string, imageData []byte, mi
|
||||
if len(imageData) == 0 {
|
||||
return "", fmt.Errorf("cover data is empty")
|
||||
}
|
||||
// Cap cached Library artwork while preserving unsupported formats.
|
||||
if resized, changed, err := resizeCoverForEmbedding(imageData, libraryCoverMaxDimension); err == nil {
|
||||
if changed {
|
||||
imageData = resized
|
||||
mimeType = embeddedCoverMIME(imageData)
|
||||
}
|
||||
} else {
|
||||
GoLog("[LibraryScan] Cover resize skipped for %s: %v\n", cacheKey, err)
|
||||
}
|
||||
if err := os.MkdirAll(cacheDir, 0755); err != nil {
|
||||
return "", fmt.Errorf("failed to create cache dir: %w", err)
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ func downloadCoverToMemory(coverURL string) ([]byte, error) {
|
||||
|
||||
const (
|
||||
embeddedCoverJPEGQuality = 88
|
||||
// Bound Library cover cache dimensions.
|
||||
libraryCoverMaxDimension = 800
|
||||
maxCoverDownloadBytes = 24 * 1024 * 1024
|
||||
// Decoding arbitrary provider artwork allocates roughly four bytes per
|
||||
// pixel. Refuse pathological images before Decode so a malicious extension
|
||||
|
||||
Reference in New Issue
Block a user