diff --git a/Aria/build.gradle b/Aria/build.gradle index 247d08ee..2b00cf71 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -26,8 +26,8 @@ dependencies { testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile project(':AriaAnnotations') - compile 'com.arialyy.aria:aria-ftp-plug:1.0.4' +// compile 'com.arialyy.aria:aria-ftp-plug:1.0.4' -// compile project(':AriaFtpPlug') + compile project(':AriaFtpPlug') } apply from: 'bintray-release.gradle' diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/BaseListener.java b/Aria/src/main/java/com/arialyy/aria/core/common/BaseListener.java index d6fde579..67a0e039 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/BaseListener.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/BaseListener.java @@ -130,6 +130,14 @@ public abstract class BaseListener { //file.skipBytes((int) mConfig.START_LOCATION); file.seek(mConfig.START_LOCATION); } - upload(client, file); - if (isBreak()) { + boolean complete = upload(client, file); + if (!complete || isBreak()) { return this; } ALog.i(TAG, @@ -131,7 +130,13 @@ class FtpThreadTask extends AbsFtpThreadTask { SERVER_CHARSET); } - private void upload(final FTPClient client, final BufferedRandomAccessFile bis) + /** + * 上传 + * + * @return {@code true}上传成功、{@code false} 上传失败 + * @throws IOException + */ + private boolean upload(final FTPClient client, final BufferedRandomAccessFile bis) throws IOException { try { @@ -156,12 +161,18 @@ class FtpThreadTask extends AbsFtpThreadTask { } }); } catch (IOException e) { + String msg = String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", client.getReplyCode(), + client.getReplyString(), mEntity.getFilePath()); + if (client.isConnected()) { + client.disconnect(); + } if (e.getMessage().contains("AriaIOException caught while copying")) { e.printStackTrace(); } else { fail(mChildCurrentLocation, - new AriaIOException(TAG, String.format("上传失败,filePath: %s", mEntity.getFilePath()), e)); + new AriaIOException(TAG, msg, e)); } + return false; } int reply = client.getReplyCode(); @@ -175,6 +186,8 @@ class FtpThreadTask extends AbsFtpThreadTask { if (client.isConnected()) { client.disconnect(); } + return false; } + return true; } } diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java index fc6f89c1..510016b1 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java @@ -35,7 +35,7 @@ class DBConfig { /*adb pull /mnt/sdcard/Android/data/com.arialyy.simple/files/DB/AriaLyyDb d:/db*/ static Map mapping = new HashMap<>(); static String DB_NAME; - static int VERSION = 41; + static int VERSION = 42; /** * 是否将数据库保存在Sd卡,{@code true} 是 diff --git a/DEV_LOG.md b/DEV_LOG.md index 33d0bb57..94b7b05f 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -2,6 +2,19 @@ + v_3.5.3 - 修复ftps不能加载默认证书的bug https://github.com/AriaLyy/Aria/issues/334 - 优化注解性能,移除不必要的判断代码 + - 增加广播支持,详情见:http://aria.laoyuyu.me/aria_doc/api/use_broadcast.html + - 增加get参数支持 + ```java + Aria.download(SingleTaskActivity.this) + .load(DOWNLOAD_URL) // url 必须是主体url,也就是?前面的内容 + .setFilePath(path, true) + .asGet() + .setParams(params) // 设置参数 + .start(); + ``` + - fix bug https://github.com/AriaLyy/Aria/issues/335 + - 新增进度百分比保存 https://github.com/AriaLyy/Aria/issues/336 + - fix bug https://github.com/AriaLyy/Aria/issues/335 + v_3.5.2 - 添加Serializable接口支持 https://github.com/AriaLyy/Aria/issues/320 - 失败回调增加错误原因 https://github.com/AriaLyy/Aria/issues/310 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 22d8cc6f..6bfc4bfb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -20,7 +20,7 @@ @@ -40,7 +40,7 @@ - + diff --git a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index 6a86534b..7c63e7aa 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -66,7 +66,8 @@ public class SingleTaskActivity extends BaseActivity { //"http://apk500.bce.baidu-mgame.com/game/67000/67734/20170622040827_oem_5502845.apk?r=1"; //"https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe"; //"http://9.9.9.50:5000/download1"; - "http://9.9.9.50:5000/download/CentOS-7-x86_64-Minimal-1804.iso"; + //"http://9.9.9.50:5000/download/CentOS-7-x86_64-Minimal-1804.iso"; + "http://cdn-s1.touchfound.com/theme/1543979562763_6907.zip"; //"https://firmwareapi.azurewebsites.net/firmware-overview?name=A19_Filament_W_IMG0038_00102411-encrypted.ota"; @Bind(R.id.start) Button mStart; @Bind(R.id.stop) Button mStop; @@ -312,8 +313,8 @@ public class SingleTaskActivity extends BaseActivity { .useServerFileName(true) .setFilePath(path, true) //.asGet() - .asPost() - .setParams(params) + //.asPost() + //.setParams(params) //.setExtendField("{\n" // + "\"id\":\"你的样子\"\n< > " // + "}") diff --git a/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java b/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java index 7a3248e2..afe2291a 100644 --- a/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java +++ b/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java @@ -22,6 +22,7 @@ import com.arialyy.annotations.Upload; import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.upload.UploadTask; +import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; import com.arialyy.frame.util.FileUtil; import com.arialyy.frame.util.show.T; @@ -35,14 +36,15 @@ import java.io.File; * Ftp 文件上传demo */ public class FtpUploadActivity extends BaseActivity { - private final String FILE_PATH = "/mnt/sdcard/sql.rar"; - private final String URL = "ftp://192.168.1.7:21/aa//你好"; + private final String FILE_PATH = "/mnt/sdcard/AriaPrj.rar"; + private final String URL = "ftp://9.9.9.50:21/aa/你好"; @Override protected void init(Bundle savedInstanceState) { setTile("D_FTP 文件上传"); super.init(savedInstanceState); Aria.upload(this).register(); UploadEntity entity = Aria.upload(this).getUploadEntity(FILE_PATH); + ALog.d(TAG, "pare = >" + entity.getPercent()); if (entity != null) { getBinding().setFileSize(CommonUtil.formatFileSize(entity.getFileSize())); getBinding().setProgress(entity.isComplete() ? 100 @@ -96,6 +98,10 @@ public class FtpUploadActivity extends BaseActivity { Log.d(TAG, "删除任务"); } + @Upload.onTaskFail public void taskFail(UploadTask task) { + Log.d(TAG, "上传失败"); + } + @Upload.onTaskRunning public void taskRunning(UploadTask task) { Log.d(TAG, "PP = " + task.getPercent()); getBinding().setProgress(task.getPercent());