Fixing 'FileTransfer.download() - should handle unknown host' failing mobile-spec test case

This commit is contained in:
Simon MacDonald 2012-08-30 17:01:16 -04:00
parent c3e17fb185
commit b3f5e039f2

View File

@ -490,8 +490,14 @@ public class FileTransfer extends Plugin {
connection.connect(); connection.connect();
Log.d(LOG_TAG, "Download file:" + url); 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]; byte[] buffer = new byte[1024];
int bytesRead = 0; int bytesRead = 0;
@ -521,6 +527,7 @@ public class FileTransfer extends Plugin {
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, connection); 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); Log.e(LOG_TAG, error.toString(), e);
return new PluginResult(PluginResult.Status.IO_EXCEPTION, error); return new PluginResult(PluginResult.Status.IO_EXCEPTION, error);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {