Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Check if external storage dir already exists to fix #128
Browse files Browse the repository at this point in the history
- Check if external storage dir already exists when trying to create it
- Get rid of erroneous warning message in said case
- Remove autoboxing of boolean value
- Add test case to verify external storage dir creation works
  • Loading branch information
matthiaswenz committed Feb 10, 2016
1 parent 89de496 commit 485d976
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
@@ -0,0 +1,31 @@
package net.hockeyapp.android;

import android.support.test.runner.AndroidJUnit4;

import junit.framework.TestCase;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.File;

/**
* <h3>Description</h3>
*
* This class provides testing for the environment features, such as the SDK wide constants.
*/
@RunWith(AndroidJUnit4.class)
public class EnvironmentTest extends TestCase {

/**
* Test to verify basic creation of the external storage directory works.
*/
@Test
public void basicStorageDirTest() {
File storageDir = Constants.getHockeyAppStorageDir();

assertNotNull(storageDir);
assertTrue(storageDir.exists());
}

}
Expand Up @@ -131,7 +131,7 @@ public static File getHockeyAppStorageDir() {
File externalStorage = Environment.getExternalStorageDirectory();

File dir = new File(externalStorage.getAbsolutePath() + "/" + Constants.FILES_DIRECTORY_NAME);
Boolean success = dir.mkdirs();
boolean success = dir.exists() || dir.mkdirs();
if (!success) {
HockeyLog.warn("Couldn't create HockeyApp Storage dir");
}
Expand Down

0 comments on commit 485d976

Please sign in to comment.