mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-12-23 05:16:58 +00:00
fix downloadworker; now functional
This commit is contained in:
parent
c47272792e
commit
bf22b86723
@ -55,9 +55,14 @@ class DownloadWorker(context: Context, workerParams: WorkerParameters) : Corouti
|
||||
.build())
|
||||
}
|
||||
val downloadRequestString: String
|
||||
val requestFile = File(downloadRequestFilePath)
|
||||
val requestFile = Uri.parse(downloadRequestFilePath)
|
||||
val context = applicationContext
|
||||
val contentResolver = context.contentResolver ?: return Result.failure(Data.Builder()
|
||||
.putString("error", "contentResolver is null")
|
||||
.build())
|
||||
try {
|
||||
downloadRequestString = requestFile.bufferedReader().use { it.readText() }
|
||||
val scanner = Scanner(contentResolver.openInputStream(requestFile))
|
||||
downloadRequestString = scanner.useDelimiter("\\A").next()
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "doWork: ", e)
|
||||
return Result.failure(Data.Builder()
|
||||
@ -82,7 +87,7 @@ class DownloadWorker(context: Context, workerParams: WorkerParameters) : Corouti
|
||||
val urlToFilePathMap = downloadRequest.urlToFilePathMap
|
||||
download(urlToFilePathMap)
|
||||
Handler(Looper.getMainLooper()).postDelayed({ showSummary(urlToFilePathMap) }, 500)
|
||||
val deleted = requestFile.delete()
|
||||
val deleted = DocumentFile.fromSingleUri(context, requestFile)!!.delete()
|
||||
if (!deleted) {
|
||||
Log.w(TAG, "doWork: requestFile not deleted!")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user