Shutdown connection manager after download
This commit is contained in:
parent
35f53c74eb
commit
cdf73fd1f7
|
@ -56,7 +56,8 @@ public class HttpDownloader extends Downloader {
|
||||||
HttpClientParams.setRedirecting(params, true);
|
HttpClientParams.setRedirecting(params, true);
|
||||||
|
|
||||||
// Workaround for broken URLs in redirection
|
// Workaround for broken URLs in redirection
|
||||||
((AbstractHttpClient)httpClient).setRedirectHandler(new APRedirectHandler());
|
((AbstractHttpClient) httpClient)
|
||||||
|
.setRedirectHandler(new APRedirectHandler());
|
||||||
return httpClient;
|
return httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +80,8 @@ public class HttpDownloader extends Downloader {
|
||||||
File destination = new File(status.getFeedFile()
|
File destination = new File(status.getFeedFile()
|
||||||
.getFile_url());
|
.getFile_url());
|
||||||
if (!destination.exists()) {
|
if (!destination.exists()) {
|
||||||
connection = AndroidHttpClient.getUngzippedContent(httpEntity);
|
connection = AndroidHttpClient
|
||||||
|
.getUngzippedContent(httpEntity);
|
||||||
InputStream in = new BufferedInputStream(connection);
|
InputStream in = new BufferedInputStream(connection);
|
||||||
out = new BufferedOutputStream(new FileOutputStream(
|
out = new BufferedOutputStream(new FileOutputStream(
|
||||||
destination));
|
destination));
|
||||||
|
@ -148,6 +150,9 @@ public class HttpDownloader extends Downloader {
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeQuietly(connection);
|
IOUtils.closeQuietly(connection);
|
||||||
IOUtils.closeQuietly(out);
|
IOUtils.closeQuietly(out);
|
||||||
|
if (httpClient != null) {
|
||||||
|
httpClient.getConnectionManager().shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,13 +186,17 @@ public class HttpDownloader extends Downloader {
|
||||||
|
|
||||||
/** Deletes unfinished downloads. */
|
/** Deletes unfinished downloads. */
|
||||||
private void cleanup() {
|
private void cleanup() {
|
||||||
if (status != null && status.getFeedFile() != null && status.getFeedFile().getFile_url() != null) {
|
if (status != null && status.getFeedFile() != null
|
||||||
|
&& status.getFeedFile().getFile_url() != null) {
|
||||||
File dest = new File(status.getFeedFile().getFile_url());
|
File dest = new File(status.getFeedFile().getFile_url());
|
||||||
if (dest.exists()) {
|
if (dest.exists()) {
|
||||||
boolean rc = dest.delete();
|
boolean rc = dest.delete();
|
||||||
if (AppConfig.DEBUG) Log.d(TAG, "Deleted file " + dest.getName() + "; Result: " + rc);
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Deleted file " + dest.getName() + "; Result: "
|
||||||
|
+ rc);
|
||||||
} else {
|
} else {
|
||||||
if (AppConfig.DEBUG) Log.d(TAG, "cleanup() didn't delete file: does not exist.");
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "cleanup() didn't delete file: does not exist.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue