Loading app/src/main/java/io/heckel/ntfy/msg/DownloadAttachmentWorker.kt +9 −5 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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 Loading
app/src/main/java/io/heckel/ntfy/msg/DownloadAttachmentWorker.kt +9 −5 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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