diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpThreadTask.java index 3bce5644..70c0f142 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpThreadTask.java @@ -87,7 +87,7 @@ public abstract class AbsFtpThreadTask mEntity.getFileSize()) { + taskBreak = true; + fail(mChildCurrentLocation, "下载失败,下载长度超出文件大小", null, false); + return; + } mChildCurrentLocation += len; STATE.CURRENT_LOCATION += len; if (System.currentTimeMillis() - mLastSaveTime > 5000 @@ -182,27 +191,36 @@ public abstract class AbsThreadTask readNormal(is); } - if (STATE.isCancel || STATE.isStop) return; + if (isBreak()){ + return; + } ALog.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】线程__" + mConfig.THREAD_ID + "__下载完毕"); writeConfig(true, 1); STATE.COMPLETE_THREAD_NUM++; @@ -146,7 +148,7 @@ class FtpThreadTask extends AbsFtpThreadTask fic = Channels.newChannel(is); ByteBuffer bf = ByteBuffer.allocate(mBufSize); while ((len = fic.read(bf)) != -1) { - if (STATE.isCancel || STATE.isStop) { + if (isBreak()) { break; } if (mSleepTime > 0) { @@ -189,7 +191,7 @@ class FtpThreadTask extends AbsFtpThreadTask byte[] buffer = new byte[mBufSize]; int len; while ((len = is.read(buffer)) != -1) { - if (STATE.isCancel || STATE.isStop) { + if (isBreak()) { break; } if (mSleepTime > 0) Thread.sleep(mSleepTime); diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java index 74d50cfb..6e290f81 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java @@ -101,7 +101,7 @@ final class HttpThreadTask extends AbsThreadTask 0) { @@ -192,7 +192,7 @@ final class HttpThreadTask extends AbsThreadTask 0) { @@ -205,10 +205,8 @@ final class HttpThreadTask extends AbsThreadTask { file.seek(mConfig.START_LOCATION); } upload(client, file); - if (STATE.isCancel || STATE.isStop) return; + if (isBreak()) { + return; + } ALog.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】线程__" + mConfig.THREAD_ID + "__上传完毕"); writeConfig(true, 1); STATE.COMPLETE_THREAD_NUM++; @@ -131,7 +133,7 @@ class FtpThreadTask extends AbsFtpThreadTask { @Override public void onFtpInputStream(FTPClient client, long totalBytesTransferred, int bytesTransferred, long streamSize) { - if ((STATE.isCancel || STATE.isStop) && !isStoped) { + if (isBreak() && !isStoped) { try { isStoped = true; client.abor(); diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c65e5e79..a81e9694 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,6 @@ - @@ -15,10 +14,10 @@ android:supportsRtl="true" android:theme="@style/AppTheme.NoActionBar"> - - + + diff --git a/app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java b/app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java index 998acc63..ff23272b 100644 --- a/app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java +++ b/app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java @@ -68,7 +68,7 @@ public class AnyRunnModule { .load(url) //.addHeader("Accept-Encoding", "gzip") .setRequestMode(RequestEnum.GET) - .setFilePath(Environment.getExternalStorageDirectory().getPath() + "/abcd.mp4") + .setFilePath(Environment.getExternalStorageDirectory().getPath() + "/abcds.exe") //.resetState() .start(); //String[] urls = new String[] {