From 351ec2e19e14d38948631169496c21ca43b68969 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Tue, 25 Jul 2017 20:45:00 +0800 Subject: [PATCH] .. --- .../download/downloader/FtpThreadTask.java | 32 +++++++++++-------- .../simple/download/FtpDownloadActivity.java | 4 ++- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpThreadTask.java index 833f3799..c4d8ff3f 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpThreadTask.java @@ -15,6 +15,8 @@ */ package com.arialyy.aria.core.download.downloader; +import android.os.Handler; +import android.os.Message; import android.text.TextUtils; import android.util.Log; import com.arialyy.aria.util.BufferedRandomAccessFile; @@ -100,21 +102,17 @@ class FtpThreadTask extends AbsThreadTask { } } if (STATE.isCancel || STATE.isStop) return; - if (client.completePendingCommand()) { - Log.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】线程__" + mConfig.THREAD_ID + "__下载完毕"); - writeConfig(true, 1); - STATE.COMPLETE_THREAD_NUM++; - if (STATE.isComplete()) { - File configFile = new File(mConfigFPath); - if (configFile.exists()) { - configFile.delete(); - } - STATE.isDownloading = false; - mListener.onComplete(); + //if (client.completePendingCommand()) { + Log.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】线程__" + mConfig.THREAD_ID + "__下载完毕"); + writeConfig(true, 1); + STATE.COMPLETE_THREAD_NUM++; + if (STATE.isComplete()) { + File configFile = new File(mConfigFPath); + if (configFile.exists()) { + configFile.delete(); } - file.close(); - is.close(); - Log.d(TAG, "SUCCESS"); + STATE.isDownloading = false; + mListener.onComplete(); } } catch (IOException e) { failDownload(mChildCurrentLocation, "下载失败【" + mConfig.DOWNLOAD_URL + "】", e); @@ -122,6 +120,12 @@ class FtpThreadTask extends AbsThreadTask { failDownload(mChildCurrentLocation, "获取流失败", e); } finally { try { + if (file != null){ + file.close(); + } + if (is != null){ + is.close(); + } if (client != null && client.isConnected()) { //client.logout(); client.disconnect(); diff --git a/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java b/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java index 36f123ac..17330201 100644 --- a/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java @@ -45,7 +45,9 @@ public class FtpDownloadActivity extends BaseActivity