Directory Bug (#1046)

The correct pattern to make a directory is: `if (!dir.mkdirs() && !dir.isDirectory()) { error }` mkdirs checks for exists so the exists check is redundant.
This commit is contained in:
Felix Bergmann 2018-07-30 00:07:39 +02:00 committed by Sean Owen
parent 96d974f44d
commit 45d89bce80

View file

@ -298,7 +298,7 @@ public final class HistoryManager {
static Uri saveHistory(String history) {
File bsRoot = new File(Environment.getExternalStorageDirectory(), "BarcodeScanner");
File historyRoot = new File(bsRoot, "History");
if (!historyRoot.exists() && !historyRoot.mkdirs()) {
if (!historyRoot.mkdirs() && !historyRoot.isDirectory()) {
Log.w(TAG, "Couldn't make dir " + historyRoot);
return null;
}