From d489c27ee0bf46cc8bfd47efaa012ad5f09c6b67 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 25 Feb 2015 10:36:10 -0800 Subject: Fix crash for some users when deleting podcasts --- src/github/daneren2005/dsub/util/FileUtil.java | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/github/daneren2005') diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java index fbfa6af0..8bd53c0c 100644 --- a/src/github/daneren2005/dsub/util/FileUtil.java +++ b/src/github/daneren2005/dsub/util/FileUtil.java @@ -501,17 +501,24 @@ public class FileUtil { } public static void deleteEmptyDir(File dir) { - File[] children = dir.listFiles(); + try { + File[] children = dir.listFiles(); + if(children == null) { + return; + } - // No songs left in the folder - if(children.length == 1 && children[0].getPath().equals(FileUtil.getAlbumArtFile(dir).getPath())) { - Util.delete(children[0]); - children = dir.listFiles(); - } + // No songs left in the folder + if (children.length == 1 && children[0].getPath().equals(FileUtil.getAlbumArtFile(dir).getPath())) { + Util.delete(children[0]); + children = dir.listFiles(); + } - // Delete empty directory - if (children.length == 0) { - Util.delete(dir); + // Delete empty directory + if (children.length == 0) { + Util.delete(dir); + } + } catch(Exception e) { + Log.w(TAG, "Error while trying to delete empty dir", e); } } -- cgit v1.2.3