Directory Bug

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-29 23:42:11 +02:00 committed by GitHub
parent 96d974f44d
commit 99ccc965bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -139,7 +139,7 @@ public final class EncodeActivity extends Activity {
File bsRoot = new File(Environment.getExternalStorageDirectory(), "BarcodeScanner");
File barcodesRoot = new File(bsRoot, "Barcodes");
if (!barcodesRoot.exists() && !barcodesRoot.mkdirs()) {
if (!barcodesRoot.mkdirs() && !barcodesRoot.isDirectory()) {
Log.w(TAG, "Couldn't make dir " + barcodesRoot);
showErrorMessage(R.string.msg_unmount_usb);
return;