more logging to detect problems with external dirs: #343

This commit is contained in:
cpfeiffer 2016-06-27 22:01:52 +02:00
parent 56615de1f0
commit 76a44ad3a4
1 changed files with 7 additions and 2 deletions

View File

@ -145,13 +145,18 @@ public class FileUtils {
} }
for (int i = 0; i < dirs.length; i++) { for (int i = 0; i < dirs.length; i++) {
File dir = dirs[i]; File dir = dirs[i];
if (dir == null || (!dir.exists() && !dir.mkdirs())) { if (dir == null) {
continue; continue;
} }
if (!dir.exists() && !dir.mkdirs()) {
GB.log("Unable to create directories: " + dir.getAbsolutePath(), GB.INFO, null);
continue;
}
// the first directory is also the primary external storage, i.e. the same as Environment.getExternalFilesDir() // the first directory is also the primary external storage, i.e. the same as Environment.getExternalFilesDir()
// TODO: check the mount state of *all* dirs when switching to later API level // TODO: check the mount state of *all* dirs when switching to later API level
if (!dir.canWrite() || (i == 0 && !Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))) { if (!dir.canWrite() || (i == 0 && !Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))) {
Log.i(TAG, "ignoring non-writable external storage dir: " + dir); GB.log("ignoring non-writable external storage dir: " + dir, GB.INFO, null);
continue; continue;
} }
result.add(dir); // add last result.add(dir); // add last