From 173fd6c1dec6d908758dfb353cdbf4119bebe113 Mon Sep 17 00:00:00 2001 From: Daniel Petrov Date: Wed, 18 Oct 2023 16:15:04 +0300 Subject: [PATCH] Allow uploading monitorings in case of missing files --- .../org/bspb/smartbirds/pro/sync/UploadManager.kt | 12 +++++++----- app/src/main/res/values-bg/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/org/bspb/smartbirds/pro/sync/UploadManager.kt b/app/src/main/kotlin/org/bspb/smartbirds/pro/sync/UploadManager.kt index 4bdcc05a..693a63c5 100644 --- a/app/src/main/kotlin/org/bspb/smartbirds/pro/sync/UploadManager.kt +++ b/app/src/main/kotlin/org/bspb/smartbirds/pro/sync/UploadManager.kt @@ -61,19 +61,21 @@ open class UploadManager { val monitoringDir = File(baseDir, monitoringCode) var hasErrors = false + var fileObjects: Map? = null if (monitoringDir.exists() && monitoringDir.isDirectory) { - var fileObjects: Map? = null - try { fileObjects = uploadMonitoringFiles(monitoringDir.absolutePath, monitoringCode) } catch (t: Throwable) { hasErrors = true } + } else { + errors.add(context.getString(R.string.sync_error_missing_files, monitoringCode)) + } - if (!uploadMonitoringEntries(monitoringCode, fileObjects)) { - hasErrors = true - } + if (!uploadMonitoringEntries(monitoringCode, fileObjects)) { + hasErrors = true } + if (hasErrors) { Toast.makeText( context, String.format( diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 74a3de85..f4870a46 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -369,6 +369,7 @@ "Детайли:" "Методика" "Липсващо изображение %s за %s" + "Липсващи файлове за %s" "---" "Внимание" "Номенлатурите на са заредени. Мола опитайте по-късно." diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index eae39dba..e2e2b082 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -370,6 +370,7 @@ Do you really want to cancel the monitoring?" "Details:" "Methodology" "Missing image %s for %s" + "Missing files for %s" "---" "Warning" "Nomenclatures are not loaded. Please try again later."