diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt index 71c03c78c..4c5c631b7 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt @@ -432,7 +432,7 @@ constructor( // Old cover revisions may be lying around, even during a normal refresh due // to really lucky cancellations. Clean those up now that it's impossible for // the rest of the app to be using them. - RevisionedCovers.cleanup(context, newRevision) + covers.cleanup(context) } private suspend fun emitIndexingProgress(progress: IndexingProgress) { diff --git a/app/src/main/java/org/oxycblt/auxio/music/RevisionedCovers.kt b/app/src/main/java/org/oxycblt/auxio/music/RevisionedCovers.kt index 5c9289d3f..0cacd3ce0 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/RevisionedCovers.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/RevisionedCovers.kt @@ -41,6 +41,15 @@ class RevisionedCovers(private val revision: UUID, private val inner: MutableSto return inner.write(data)?.let { RevisionedCover(revision, it) } } + suspend fun cleanup(context: Context) = + withContext(Dispatchers.IO) { + val exclude = revision.toString() + context.filesDir + .resolve("covers") + .listFiles { file -> file.name != exclude } + ?.forEach { it.deleteRecursively() } + } + companion object { suspend fun at(context: Context, revision: UUID): RevisionedCovers { val dir = @@ -52,15 +61,6 @@ class RevisionedCovers(private val revision: UUID, private val inner: MutableSto StoredCovers.from(CoverFiles.at(dir), CoverFormat.jpeg(CoverParams.of(750, 80)))) } - suspend fun cleanup(context: Context, exclude: UUID) = - withContext(Dispatchers.IO) { - val excludeName = exclude.toString() - context.filesDir - .resolve("covers") - .listFiles { file -> file.name != excludeName } - ?.forEach { it.deleteRecursively() } - } - private fun parse(id: String): Pair? { val split = id.split('@', limit = 2) if (split.size != 2) return null