From d7198bd68cbc6f8c051d0cb2b76bee7177a3d4b0 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 7 Feb 2017 10:20:13 +0100 Subject: [PATCH] fixed rare npe when doing file migration --- .../eu/siacs/conversations/persistance/DatabaseBackend.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index e66870f24..e2c7747b4 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -411,7 +411,11 @@ public class DatabaseBackend extends SQLiteOpenHelper { if (oldFilesDirectory.exists() && oldFilesDirectory.isDirectory()) { newFilesDirectory.mkdirs(); newVideosDirectory.mkdirs(); - for(File file : oldFilesDirectory.listFiles()) { + final File[] files = oldFilesDirectory.listFiles(); + if (files == null) { + return; + } + for(File file : files) { if (file.getName().equals(".nomedia")) { if (file.delete()) { Log.d(Config.LOGTAG,"deleted nomedia file in "+oldFilesDirectory.getAbsolutePath());