added download crashing when creating logfile with unwanted characters

This commit is contained in:
deniscerri 2023-03-18 19:43:21 +01:00
parent 800b82b7bd
commit 17c85f9280
No known key found for this signature in database
GPG key ID: 95C43D517D830350

View file

@ -210,7 +210,9 @@ class DownloadWorker(
runCatching {
val logDownloads = sharedPreferences.getBoolean("log_downloads", false) && !sharedPreferences.getBoolean("incognito", false)
val logFolder = File(context.filesDir.absolutePath + "/logs")
val logFile = File(context.filesDir.absolutePath + """/logs/${downloadItem.id} - ${downloadItem.title}##${downloadItem.type}##${downloadItem.format.format_id}.log""")
val regex = Regex("[^A-Za-z\\d ]")
val logFile = File(context.filesDir.absolutePath + """/logs/${downloadItem.id} - ${regex.replace(downloadItem.title, "")}##${downloadItem.type}##${downloadItem.format.format_id}.log""")
Log.e("aa", logFile.name)
if (logDownloads){
logFolder.mkdirs()
logFile.createNewFile()