musikr: offload storage dir creation to client

This commit is contained in:
Alexander Capehart 2025-03-18 11:56:04 -06:00
parent e7454e636b
commit 132b689b0c
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 2 additions and 3 deletions

View file

@ -70,4 +70,4 @@ class SettingCoversImpl @Inject constructor(private val imageSettings: ImageSett
} }
} }
private fun Context.coversDir() = filesDir.resolve("covers") private fun Context.coversDir() = filesDir.resolve("covers").apply { mkdirs() }

View file

@ -82,8 +82,7 @@ interface CoverStorage {
*/ */
suspend fun at(dir: File): CoverStorage { suspend fun at(dir: File): CoverStorage {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
if (dir.exists()) check(dir.isDirectory) { "Not a directory" } check(dir.exists() && dir.isDirectory) { "Not a existent directory" }
else check(dir.mkdirs()) { "Cannot create directory" }
} }
return FSCoverStorage(dir) return FSCoverStorage(dir)
} }