feat(ui): surface the audio-analysis cache in cache management

This commit is contained in:
zarzet
2026-07-14 09:10:05 +07:00
parent c1737b92d0
commit 556399d354
18 changed files with 163 additions and 0 deletions
+12
View File
@@ -3914,6 +3914,18 @@ abstract class AppLocalizations {
/// **'Cover art extracted from local music files. Will re-extract on next scan.'**
String get cacheLibraryCoverDesc;
/// Cache item title for saved audio analysis results
///
/// In en, this message translates to:
/// **'Audio analysis cache'**
String get cacheAudioAnalysis;
/// Description of what audio analysis cache contains
///
/// In en, this message translates to:
/// **'Saved spectrograms and analysis results. Will re-analyze on next open.'**
String get cacheAudioAnalysisDesc;
/// Cache item title for explore home feed cache
///
/// In en, this message translates to:
+7
View File
@@ -2185,6 +2185,13 @@ class AppLocalizationsAr extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Cover art extracted from local music files. Will re-extract on next scan.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Explore feed cache';
+7
View File
@@ -2213,6 +2213,13 @@ class AppLocalizationsDe extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Cover aus lokalen Musikdateien extrahiert. Wird beim nächsten Scannen neu extrahiert.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Feed-Cache entdecken';
+7
View File
@@ -2185,6 +2185,13 @@ class AppLocalizationsEn extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Cover art extracted from local music files. Will re-extract on next scan.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Explore feed cache';
+7
View File
@@ -2185,6 +2185,13 @@ class AppLocalizationsEs extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Cover art extracted from local music files. Will re-extract on next scan.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Explore feed cache';
+7
View File
@@ -2243,6 +2243,13 @@ class AppLocalizationsFr extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Pochettes extraites des fichiers musicaux locaux. Elles seront extraites à nouveau lors de la prochaine analyse.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Explorer le cache des flux';
+7
View File
@@ -2185,6 +2185,13 @@ class AppLocalizationsHi extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Cover art extracted from local music files. Will re-extract on next scan.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Explore feed cache';
+7
View File
@@ -2194,6 +2194,13 @@ class AppLocalizationsId extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Cover art extracted from local music files. Will re-extract on next scan.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Explore feed cache';
+7
View File
@@ -2174,6 +2174,13 @@ class AppLocalizationsJa extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Cover art extracted from local music files. Will re-extract on next scan.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Explore feed cache';
+7
View File
@@ -2123,6 +2123,13 @@ class AppLocalizationsKo extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'로컬 음악 파일에서 표지 이미지를 추출하였습니다. 다음 스캔 시 다시 추출합니다';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => '탐색 피드 캐시';
+7
View File
@@ -2185,6 +2185,13 @@ class AppLocalizationsNl extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Cover art extracted from local music files. Will re-extract on next scan.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Explore feed cache';
+7
View File
@@ -2185,6 +2185,13 @@ class AppLocalizationsPt extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Cover art extracted from local music files. Will re-extract on next scan.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Explore feed cache';
+7
View File
@@ -2214,6 +2214,13 @@ class AppLocalizationsRu extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Обложка извлечена из локальных музыкальных файлов. Будет повторно извлечено при следующем сканировании.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Просмотреть кэш ленты';
+7
View File
@@ -2211,6 +2211,13 @@ class AppLocalizationsTr extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Kapak resmi yerel müzik dosyalarından çıkarıldı. Bir sonraki taramada yeniden çıkarılacaktır.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Besleme önbelleğini keşfedin';
+7
View File
@@ -2218,6 +2218,13 @@ class AppLocalizationsUk extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Обкладинку витягнуто з локальних музичних файлів. Буде повторно витягнуто під час наступного сканування.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Огляд кешу стрічки';
+7
View File
@@ -2185,6 +2185,13 @@ class AppLocalizationsZh extends AppLocalizations {
String get cacheLibraryCoverDesc =>
'Cover art extracted from local music files. Will re-extract on next scan.';
@override
String get cacheAudioAnalysis => 'Audio analysis cache';
@override
String get cacheAudioAnalysisDesc =>
'Saved spectrograms and analysis results. Will re-analyze on next open.';
@override
String get cacheExploreFeed => 'Explore feed cache';
+8
View File
@@ -2860,6 +2860,14 @@
"@cacheLibraryCoverDesc": {
"description": "Description of what library cover cache contains"
},
"cacheAudioAnalysis": "Audio analysis cache",
"@cacheAudioAnalysis": {
"description": "Cache item title for saved audio analysis results"
},
"cacheAudioAnalysisDesc": "Saved spectrograms and analysis results. Will re-analyze on next open.",
"@cacheAudioAnalysisDesc": {
"description": "Description of what audio analysis cache contains"
},
"cacheExploreFeed": "Explore feed cache",
"@cacheExploreFeed": {
"description": "Cache item title for explore home feed cache"
@@ -84,6 +84,9 @@ class _CacheManagementPageState extends ConsumerState<CacheManagementPage> {
final libraryCoverStatsFuture = _scanDirectory(
Directory('${appSupportDir.path}/library_covers'),
);
final audioAnalysisStatsFuture = _scanDirectory(
Directory('${appSupportDir.path}/audio_analysis_cache'),
);
final prefs = await prefsFuture;
final explorePayload = prefs.getString(_exploreCacheKey);
@@ -101,6 +104,7 @@ class _CacheManagementPageState extends ConsumerState<CacheManagementPage> {
final tempStats = await tempStatsFuture;
final coverStats = await coverStatsFuture;
final libraryCoverStats = await libraryCoverStatsFuture;
final audioAnalysisStats = await audioAnalysisStatsFuture;
final trackCacheEntries = await trackCacheEntriesFuture;
return _CacheOverview(
@@ -111,6 +115,7 @@ class _CacheManagementPageState extends ConsumerState<CacheManagementPage> {
tempIsSameAsAppCache: tempIsSameAsAppCache,
coverStats: coverStats,
libraryCoverStats: libraryCoverStats,
audioAnalysisStats: audioAnalysisStats,
exploreCacheBytes: exploreBytes,
hasExploreCache: hasExploreCache,
trackCacheEntries: trackCacheEntries,
@@ -199,6 +204,12 @@ class _CacheManagementPageState extends ConsumerState<CacheManagementPage> {
await _clearDirectoryContents(libraryCoverDir.path);
}
Future<void> _clearAudioAnalysisCache() async {
final appSupportDir = await getApplicationSupportDirectory();
final analysisDir = Directory('${appSupportDir.path}/audio_analysis_cache');
await _clearDirectoryContents(analysisDir.path);
}
Future<void> _clearExploreCache() async {
final prefs = await SharedPreferences.getInstance();
await prefs.remove(_exploreCacheKey);
@@ -217,6 +228,7 @@ class _CacheManagementPageState extends ConsumerState<CacheManagementPage> {
}
await _clearCoverCache();
await _clearLibraryCoverCache();
await _clearAudioAnalysisCache();
await _clearExploreCache();
await _clearTrackCache();
}
@@ -547,6 +559,30 @@ class _CacheManagementPageState extends ConsumerState<CacheManagementPage> {
),
),
),
SettingsItem(
icon: Icons.graphic_eq_outlined,
title: context.l10n.cacheAudioAnalysis,
subtitle: _buildSubtitle(
context.l10n.cacheAudioAnalysisDesc,
overview.audioAnalysisStats.fileCount > 0 &&
overview.audioAnalysisStats.totalSizeBytes > 0
? context.l10n.cacheSizeWithFiles(
formatBytes(
overview.audioAnalysisStats.totalSizeBytes,
),
overview.audioAnalysisStats.fileCount,
)
: context.l10n.cacheNoData,
),
trailing: _buildClearTrailing(
'clear_audio_analysis_cache',
() => _confirmAndRunAction(
actionKey: 'clear_audio_analysis_cache',
targetLabel: context.l10n.cacheAudioAnalysis,
action: _clearAudioAnalysisCache,
),
),
),
SettingsItem(
icon: Icons.explore_outlined,
title: context.l10n.cacheExploreFeed,
@@ -631,6 +667,7 @@ class _CacheOverview {
final bool tempIsSameAsAppCache;
final CacheStats coverStats;
final _DirectoryStats libraryCoverStats;
final _DirectoryStats audioAnalysisStats;
final int exploreCacheBytes;
final bool hasExploreCache;
final int trackCacheEntries;
@@ -643,6 +680,7 @@ class _CacheOverview {
required this.tempIsSameAsAppCache,
required this.coverStats,
required this.libraryCoverStats,
required this.audioAnalysisStats,
required this.exploreCacheBytes,
required this.hasExploreCache,
required this.trackCacheEntries,