From 7790b1d28cffb33cba90f95f36b9d26658f04d8e Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Wed, 1 May 2019 20:22:52 +0400 Subject: [PATCH] Small updates to logging (#1172) Don't log expected exceptions. Log more data about why directories are null if they are null. --- .../androidquran/presenter/data/QuranDataPresenter.kt | 9 +++++---- .../com/quran/labs/androidquran/util/QuranFileUtils.java | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/quran/labs/androidquran/presenter/data/QuranDataPresenter.kt b/app/src/main/java/com/quran/labs/androidquran/presenter/data/QuranDataPresenter.kt index dc9b7e1da8..adebd030f6 100644 --- a/app/src/main/java/com/quran/labs/androidquran/presenter/data/QuranDataPresenter.kt +++ b/app/src/main/java/com/quran/labs/androidquran/presenter/data/QuranDataPresenter.kt @@ -88,8 +88,9 @@ class QuranDataPresenter @Inject internal constructor( directory?.let { val log = StringBuilder() - val quranImagesDirectory = quranFileUtils.getQuranImagesBaseDirectory(appContext) - val quranImagesDirectoryFiles = File(quranImagesDirectory).listFiles() + val quranImagesDirectoryName = quranFileUtils.getQuranImagesBaseDirectory(appContext) + val quranImagesDirectory = File(quranImagesDirectoryName) + val quranImagesDirectoryFiles = quranImagesDirectory.listFiles() quranImagesDirectoryFiles?.let { files -> val imageSubdirectories = files.filter { it.name.contains("width_") } imageSubdirectories.map { @@ -110,13 +111,13 @@ class QuranDataPresenter @Inject internal constructor( log.append("\n") if (imageFiles == null) { - log.append("null image file list") + log.append("null image file list, $it - ${it.isDirectory}") } } } if (quranImagesDirectoryFiles == null) { - log.append("null list of files in images directory") + log.append("null list of files in images directory: $quranImagesDirectoryName - ${quranImagesDirectory.isDirectory}") } val audioDirectory = quranFileUtils.getQuranAudioDirectory(appContext) diff --git a/app/src/main/java/com/quran/labs/androidquran/util/QuranFileUtils.java b/app/src/main/java/com/quran/labs/androidquran/util/QuranFileUtils.java index f584ae9605..0c5a0c352c 100644 --- a/app/src/main/java/com/quran/labs/androidquran/util/QuranFileUtils.java +++ b/app/src/main/java/com/quran/labs/androidquran/util/QuranFileUtils.java @@ -16,6 +16,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.InterruptedIOException; import java.io.OutputStream; import java.text.NumberFormat; import java.util.ArrayList; @@ -275,6 +276,8 @@ private Response getImageFromWeb(OkHttpClient okHttpClient, } } } + } catch (InterruptedIOException iioe) { + // do nothing, this is expected if the job is canceled } catch (IOException ioe) { Timber.e(ioe, "exception downloading file"); } finally {