fixed rare npe when doing file migration

This commit is contained in:
Daniel Gultsch 2017-02-07 10:20:13 +01:00
parent 6fc67d9a60
commit d7198bd68c
1 changed files with 5 additions and 1 deletions

View File

@ -411,7 +411,11 @@ public class DatabaseBackend extends SQLiteOpenHelper {
if (oldFilesDirectory.exists() && oldFilesDirectory.isDirectory()) { if (oldFilesDirectory.exists() && oldFilesDirectory.isDirectory()) {
newFilesDirectory.mkdirs(); newFilesDirectory.mkdirs();
newVideosDirectory.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.getName().equals(".nomedia")) {
if (file.delete()) { if (file.delete()) {
Log.d(Config.LOGTAG,"deleted nomedia file in "+oldFilesDirectory.getAbsolutePath()); Log.d(Config.LOGTAG,"deleted nomedia file in "+oldFilesDirectory.getAbsolutePath());