close http download connection after download
This commit is contained in:
		
							parent
							
								
									7ba81177c6
								
							
						
					
					
						commit
						1a72683b52
					
				| @ -219,6 +219,7 @@ public class HttpDownloadConnection implements Transferable { | |||||||
| 				} | 				} | ||||||
| 				return Long.parseLong(contentLength, 10); | 				return Long.parseLong(contentLength, 10); | ||||||
| 			} catch (IOException e) { | 			} catch (IOException e) { | ||||||
|  | 				Log.d(Config.LOGTAG,"io exception during HEAD "+e.getMessage()); | ||||||
| 				throw e; | 				throw e; | ||||||
| 			} catch (NumberFormatException e) { | 			} catch (NumberFormatException e) { | ||||||
| 				throw new IOException(); | 				throw new IOException(); | ||||||
| @ -259,10 +260,10 @@ public class HttpDownloadConnection implements Transferable { | |||||||
| 
 | 
 | ||||||
| 		private void download()  throws Exception { | 		private void download()  throws Exception { | ||||||
| 			InputStream is = null; | 			InputStream is = null; | ||||||
|  | 			HttpURLConnection connection = null; | ||||||
| 			PowerManager.WakeLock wakeLock = mHttpConnectionManager.createWakeLock("http_download_"+message.getUuid()); | 			PowerManager.WakeLock wakeLock = mHttpConnectionManager.createWakeLock("http_download_"+message.getUuid()); | ||||||
| 			try { | 			try { | ||||||
| 				wakeLock.acquire(); | 				wakeLock.acquire(); | ||||||
| 				HttpURLConnection connection; |  | ||||||
| 				if (mUseTor) { | 				if (mUseTor) { | ||||||
| 					connection = (HttpURLConnection) mUrl.openConnection(mHttpConnectionManager.getProxy()); | 					connection = (HttpURLConnection) mUrl.openConnection(mHttpConnectionManager.getProxy()); | ||||||
| 				} else { | 				} else { | ||||||
| @ -322,10 +323,14 @@ public class HttpDownloadConnection implements Transferable { | |||||||
| 					throw new FileWriterException(); | 					throw new FileWriterException(); | ||||||
| 				} | 				} | ||||||
| 			} catch (CancellationException | IOException e) { | 			} catch (CancellationException | IOException e) { | ||||||
|  | 				Log.d(Config.LOGTAG,"http download failed "+e.getMessage()); | ||||||
| 				throw e; | 				throw e; | ||||||
| 			} finally { | 			} finally { | ||||||
| 				FileBackend.close(os); | 				FileBackend.close(os); | ||||||
| 				FileBackend.close(is); | 				FileBackend.close(is); | ||||||
|  | 				if (connection != null) { | ||||||
|  | 					connection.disconnect(); | ||||||
|  | 				} | ||||||
| 				wakeLock.release(); | 				wakeLock.release(); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Daniel Gultsch
						Daniel Gultsch