From 6065a6e984c51bc360b654ab86321d95b4f756ca Mon Sep 17 00:00:00 2001 From: Ido Ben-Hur Date: Sat, 29 Oct 2022 13:28:31 +0300 Subject: [PATCH] OpenDelta: No NPE please Happens very very rarely --- src/eu/chainfire/opendelta/UpdateService.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/eu/chainfire/opendelta/UpdateService.java b/src/eu/chainfire/opendelta/UpdateService.java index 8edd7b4..cd7a04e 100644 --- a/src/eu/chainfire/opendelta/UpdateService.java +++ b/src/eu/chainfire/opendelta/UpdateService.java @@ -483,13 +483,15 @@ public class UpdateService extends Service implements OnNetworkStateListener, if (latestBuild != null) { File found = null; File[] files = new File(mConfig.getPathBase()).listFiles(); - for (File file : files) { - String currName = file.getName(); - if (file.isFile() && currName.endsWith(".part")) { - if (currName.equals(latestBuild + ".part")) - found = file; - else - file.delete(); // remove old .part files + if (files != null && files.length > 0) { + for (File file : files) { + String currName = file.getName(); + if (file.isFile() && currName.endsWith(".part")) { + if (currName.equals(latestBuild + ".part")) + found = file; + else + file.delete(); // remove old .part files + } } } if (found != null) {