remove attachment download limit if userAction
This commit is contained in:
parent
fcce44bef1
commit
433fad761a
1 changed files with 9 additions and 5 deletions
|
@ -82,11 +82,7 @@ class DownloadAttachmentWorker(private val context: Context, params: WorkerParam
|
|||
Log.d(TAG, "Starting download to content URI: $uri")
|
||||
var bytesCopied: Long = 0
|
||||
val outFile = resolver.openOutputStream(uri) ?: throw Exception("Cannot open output stream")
|
||||
val downloadLimit = if (repository.getAutoDownloadMaxSize() != Repository.AUTO_DOWNLOAD_NEVER && repository.getAutoDownloadMaxSize() != Repository.AUTO_DOWNLOAD_ALWAYS) {
|
||||
repository.getAutoDownloadMaxSize()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val downloadLimit = getDownloadLimit(userAction)
|
||||
outFile.use { fileOut ->
|
||||
val fileIn = response.body!!.byteStream()
|
||||
val buffer = ByteArray(BUFFER_SIZE)
|
||||
|
@ -192,6 +188,14 @@ class DownloadAttachmentWorker(private val context: Context, params: WorkerParam
|
|||
}
|
||||
}
|
||||
|
||||
private fun getDownloadLimit(userAction: Boolean): Long? {
|
||||
return if (userAction || repository.getAutoDownloadMaxSize() == Repository.AUTO_DOWNLOAD_ALWAYS) {
|
||||
null
|
||||
} else {
|
||||
repository.getAutoDownloadMaxSize()
|
||||
}
|
||||
}
|
||||
|
||||
private fun createUri(notification: Notification): Uri {
|
||||
val attachmentDir = File(context.cacheDir, ATTACHMENT_CACHE_DIR)
|
||||
if (!attachmentDir.exists() && !attachmentDir.mkdirs()) {
|
||||
|
|
Loading…
Reference in a new issue