Skip to content

Commit

Permalink
[Fix] create media and artwork folder if not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
z-huang committed Apr 11, 2022
1 parent 7214b3d commit f81e8e4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/src/main/java/com/zionhuang/music/repos/SongRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,15 @@ object SongRepository : LocalRepository {
}

override fun getSongFile(songId: String): File {
return context.getExternalFilesDir(null)!! / "media" / md5(songId)
val mediaDir = context.getExternalFilesDir(null)!! / "media"
if (!mediaDir.isDirectory) mediaDir.mkdirs()
return mediaDir / md5(songId)
}

override fun getSongArtworkFile(songId: String): File {
return context.getExternalFilesDir(null)!! / "artwork" / md5(songId)
val artworkDir = context.getExternalFilesDir(null)!! / "artwork"
if (!artworkDir.isDirectory) artworkDir.mkdirs()
return artworkDir / md5(songId)
}


Expand Down

0 comments on commit f81e8e4

Please # to comment.