Skip to content

Commit

Permalink
Fixing 'FileTransfer.download() - should handle unknown host' failing…
Browse files Browse the repository at this point in the history
… mobile-spec test case
  • Loading branch information
macdonst committed Aug 30, 2012
1 parent c3e17fb commit b3f5e03
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion framework/src/org/apache/cordova/FileTransfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,14 @@ private PluginResult download(String source, String target) {
connection.connect();

Log.d(LOG_TAG, "Download file:" + url);
InputStream inputStream;
try {
inputStream = connection.getInputStream();
} catch(FileNotFoundException e) {
Log.e(LOG_TAG, e.toString(), e);
throw new IOException("Received error from server");
}

InputStream inputStream = connection.getInputStream();
byte[] buffer = new byte[1024];
int bytesRead = 0;

Expand Down Expand Up @@ -521,6 +527,7 @@ private PluginResult download(String source, String target) {

} catch (FileNotFoundException e) {
JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, connection);
Log.d(LOG_TAG, "I got a file not found exception");
Log.e(LOG_TAG, error.toString(), e);
return new PluginResult(PluginResult.Status.IO_EXCEPTION, error);
} catch (MalformedURLException e) {
Expand Down

0 comments on commit b3f5e03

Please sign in to comment.