Skip to content

Commit

Permalink
#20: Bugfix crash when trying to write to root directory
Browse files Browse the repository at this point in the history
  • Loading branch information
k3b committed Jun 5, 2019
1 parent 2153623 commit 22987ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.provider.DocumentsContract;
import android.support.v4.provider.DocumentFile;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -158,7 +159,11 @@ public static String getPath(final Context context, final Uri uri) {
final String type = split[0];

if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
final File externalStorageDirectory = Environment.getExternalStorageDirectory();

// split[1] results in index out of bound exception in storage root dir
if (split.length == 1) return externalStorageDirectory.toString();
return externalStorageDirectory + "/" + split[1];
}

// TODO handle non-primary volumes
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/20.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* Bugfix crash when trying to write to root directory #20
* Translation update ar
9 changes: 0 additions & 9 deletions libK3b/libK3b.iml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="Gradle: slf4j-api-1.7.7" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: slf4j-simple-1.7.7" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: powermock-module-junit4-1.5.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: powermock-module-junit4-common-1.5.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: junit-4.11" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: powermock-api-mockito-1.5.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: mockito-all-1.9.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: powermock-api-support-1.5.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: powermock-core-1.5.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: powermock-reflect-1.5.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: javassist-3.18.0-GA" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="Gradle: objenesis-1.2" level="project" />
</component>
</module>

0 comments on commit 22987ba

Please sign in to comment.