From 564a5fe2c75fe336917041a5a37eec77cf5bf3e2 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 31 Oct 2024 09:31:31 +0100 Subject: [PATCH] only make improvement for fileDownloadHelper Signed-off-by: alperozturk --- .../nextcloud/client/jobs/FilesExportWork.kt | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/FilesExportWork.kt b/app/src/main/java/com/nextcloud/client/jobs/FilesExportWork.kt index 49b9013f1f..812be5cb75 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/FilesExportWork.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/FilesExportWork.kt @@ -58,7 +58,6 @@ class FilesExportWork( private fun exportFiles(fileIDs: LongArray): Int { val fileDownloadHelper = FileDownloadHelper.instance() - val fileExportUtil = FileExportUtils() var successfulExports = 0 fileIDs @@ -73,13 +72,7 @@ class FilesExportWork( if (ocFile.isDown) { try { - fileExportUtil.exportFile( - ocFile.fileName, - ocFile.mimeType, - contentResolver, - ocFile, - null - ) + exportFile(ocFile) } catch (e: IllegalStateException) { Log_OC.e(TAG, "Error exporting file", e) showErrorNotification(successfulExports) @@ -97,6 +90,17 @@ class FilesExportWork( return successfulExports } + @Throws(IllegalStateException::class) + private fun exportFile(ocFile: OCFile) { + FileExportUtils().exportFile( + ocFile.fileName, + ocFile.mimeType, + contentResolver, + ocFile, + null + ) + } + private fun showErrorNotification(successfulExports: Int) { val message = if (successfulExports == 0) { appContext.resources.getQuantityString(R.plurals.export_failed, successfulExports, successfulExports)