forked from upstream-mirrors/OpenTracks
Check if SD card is available before building external directory path.
This commit is contained in:
@@ -194,23 +194,22 @@ class TrackWriterImpl implements TrackWriter {
|
|||||||
* Checks and returns whether we're ready to create the output file.
|
* Checks and returns whether we're ready to create the output file.
|
||||||
*/
|
*/
|
||||||
protected boolean canWriteFile() {
|
protected boolean canWriteFile() {
|
||||||
if (directory == null) {
|
|
||||||
String dirName =
|
|
||||||
FileUtils.buildExternalDirectoryPath(writer.getExtension());
|
|
||||||
directory = newFile(dirName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FileUtils.isSdCardAvailable()) {
|
if (!FileUtils.isSdCardAvailable()) {
|
||||||
Log.i(Constants.TAG, "Could not find SD card.");
|
Log.i(Constants.TAG, "Could not find SD card.");
|
||||||
errorMessage = R.string.external_storage_error_no_storage;
|
errorMessage = R.string.external_storage_error_no_storage;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (directory == null) {
|
||||||
|
String dirName =
|
||||||
|
FileUtils.buildExternalDirectoryPath(writer.getExtension());
|
||||||
|
directory = newFile(dirName);
|
||||||
|
}
|
||||||
if (!FileUtils.ensureDirectoryExists(directory)) {
|
if (!FileUtils.ensureDirectoryExists(directory)) {
|
||||||
Log.i(Constants.TAG, "Could not create export directory.");
|
Log.i(Constants.TAG, "Could not create export directory.");
|
||||||
errorMessage = R.string.external_storage_save_error_create_dir;
|
errorMessage = R.string.external_storage_save_error_create_dir;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user