Skip to content

Commit

Permalink
Merge pull request #446 from Reco1I/escape-slash-bmap-downloader
Browse files Browse the repository at this point in the history
Escape slash character in filenames from the beatmap downloader
  • Loading branch information
Rian8337 authored Nov 13, 2024
2 parents 2dde03c + a76759c commit 558cd3e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/com/reco1l/osu/beatmaplisting/BeatmapDownloader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ object BeatmapDownloader : IDownloaderObserver {


fun download(url: String, suggestedFilename: String) {

if (isDownloading) {
return
}
isDownloading = true

currentFilename = suggestedFilename
// Slash is the only character that is not allowed for filenames in the Android filesystem (which is just a Linux filesystem).
currentFilename = suggestedFilename.replace('/', ' ')

val file = context.getExternalFilesDir(DIRECTORY_DOWNLOADS)!!.resolve("$suggestedFilename.osz")
val file = context.getExternalFilesDir(DIRECTORY_DOWNLOADS)!!.resolve("$currentFilename.osz")

val downloader = FileRequest(file, url)
downloader.buildRequest { header("User-Agent", "Chrome/Android") }
Expand Down

0 comments on commit 558cd3e

Please sign in to comment.