修复FTP上传进度保存失败问题

pull/330/head
laoyuyu 7 years ago
parent 8c0eeaa035
commit c273dfbfa7
  1. 1
      Aria/src/main/java/com/arialyy/aria/core/common/ProxyHelper.java
  2. 1
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java
  3. 2
      Aria/src/main/java/com/arialyy/aria/core/download/FtpDownloadTarget.java
  4. 10
      Aria/src/main/java/com/arialyy/aria/core/manager/UTEFactory.java
  5. 1
      Aria/src/main/java/com/arialyy/aria/core/upload/BaseNormalTarget.java
  6. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/FtpFileInfoThread.java
  7. 2
      Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java
  8. 2
      DEV_LOG.md
  9. 16
      app/build.gradle
  10. 6
      app/src/main/AndroidManifest.xml
  11. 2
      app/src/main/java/com/arialyy/simple/test/AnyRunActivity.java
  12. 2
      app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java
  13. 13
      app/src/main/java/com/arialyy/simple/test/TestActivity.java

@ -52,7 +52,6 @@ public class ProxyHelper {
if (!className.startsWith("com.arialyy.aria.ProxyClassCounter")){
continue;
}
ALog.d("TAG", className);
count(className);
}
}

@ -49,7 +49,6 @@ public class DownloadTarget extends BaseNormalTarget<DownloadTarget>
/**
* 是否使用服务器通过content-disposition传递的文件名内容格式{@code attachment;filename=***}
* 如果获取不到服务器文件名则使用用户设置的文件名
* 只适用于HTTP请求
*
* @param use {@code true} 使用
*/

@ -68,8 +68,6 @@ public class FtpDownloadTarget extends BaseNormalTarget<FtpDownloadTarget>
* 关于文件名
* 1如果保存路径是该文件的保存路径/mnt/sdcard/file.zip则使用路径中的文件名file.zip
* 2如果保存路径是文件夹路径/mnt/sdcard/则使用FTP服务器该文件的文件名
*
* @param filePath 路径必须为文件路径不能为文件夹路径
*/
public FtpDownloadTarget setFilePath(@NonNull String filePath) {
mTempFilePath = filePath;

@ -48,9 +48,9 @@ class UTEFactory implements INormalTEFactory<UploadEntity, UploadTaskEntity> {
List<UTEWrapper> wrapper =
DbEntity.findRelationData(UTEWrapper.class, "UploadTaskEntity.key=?",
entity.getFilePath());
UploadTaskEntity uTaskEntity = null;
if (wrapper != null && !wrapper.isEmpty()) {
UploadTaskEntity uTaskEntity = wrapper.get(0).taskEntity;
uTaskEntity = wrapper.get(0).taskEntity;
if (uTaskEntity == null) {
uTaskEntity = new UploadTaskEntity();
uTaskEntity.setEntity(entity);
@ -58,12 +58,12 @@ class UTEFactory implements INormalTEFactory<UploadEntity, UploadTaskEntity> {
uTaskEntity.getEntity().getFilePath())) {
uTaskEntity.setEntity(entity);
}
return uTaskEntity;
} else {
UploadTaskEntity uTaskEntity = new UploadTaskEntity();
uTaskEntity = new UploadTaskEntity();
uTaskEntity.setEntity(entity);
return uTaskEntity;
}
uTaskEntity.setKey(entity.getFilePath());
return uTaskEntity;
}
@Override public UploadTaskEntity create(String key) {

@ -105,6 +105,7 @@ abstract class BaseNormalTarget<TARGET extends AbsUploadTarget>
ALog.e(TAG, "上传失败,文件【" + filePath + "】不能是文件夹");
return false;
}
mTaskEntity.setKey(mEntity.getFilePath());
return true;
}

@ -32,7 +32,7 @@ import org.apache.commons.net.ftp.FTPFile;
* 单任务上传远程服务器文件信息
*/
class FtpFileInfoThread extends AbsFtpInfoThread<UploadEntity, UploadTaskEntity> {
private static final String TAG = "FtpUploadFtpFileInfoThread";
private static final String TAG = "FtpUploadFileInfoThread";
static final int CODE_COMPLETE = 0xab1;
private boolean isComplete = false;

@ -91,7 +91,6 @@ public class CommonUtil {
if (!fPath.endsWith(".apk")) {
continue;
}
ALog.d(TAG, fPath);
DexFile df = new DexFile(fPath);//通过DexFile查找当前的APK中可执行文件
Enumeration<String> enumeration = df.entries();//获取df中的元素 这里包含了所有可执行的类名 该类名包含了包名+类名的方式
while (enumeration.hasMoreElements()) {//遍历
@ -100,6 +99,7 @@ public class CommonUtil {
classNameList.add(className);
}
}
df.close();
}
} catch (IOException e) {
e.printStackTrace();

@ -4,6 +4,8 @@
- 上传配置添加io超时时间、缓存大小配置
- 添加没有网络也会重试的开关
- 修复多次删除记录的bug
- 文件长度现在可动态增加,详情见 https://aria.laoyuyu.me/aria_doc/start/config.html
- 修复多module同时引用Aria导致打正式包出错的问题 https://github.com/AriaLyy/Aria/issues/240
+ v_3.4
- 优化大量代码
- 重构Aria的ORM模型,提高了数据读取的可靠性和读写速度

@ -34,11 +34,10 @@ android {
abortOnError false
}
// sourceSets {
// main.kotlin.srcDirs += 'src/main/kotlin'
// main.java.srcDirs += 'src/main/java'
// }
// sourceSets {
// main.kotlin.srcDirs += 'src/main/kotlin'
// main.java.srcDirs += 'src/main/java'
// }
}
dependencies {
@ -52,9 +51,10 @@ dependencies {
compile 'com.arialyy.frame:MVVM2:2.2.0'
compile project(':Aria')
compile project(':AriaCompiler')
// compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
// compile 'com.arialyy.aria:aria-core:3.3.16'
// annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.16'
// compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
// compile 'com.arialyy.aria:aria-core:3.3.16'
// annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.16'
debugCompile 'com.amitshekhar.android:debug-db:1.0.0'
}
repositories {
mavenCentral()

@ -15,10 +15,10 @@
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<!--android:name=".test.TestGroupActivity"-->
<!--android:name=".MainActivity"-->
<!--android:name=".test.TestActivity"-->
<!--android:name=".MainActivity"-->
<!--android:name=".test.AnyRunActivity"-->
<activity
android:name=".test.AnyRunActivity"
android:name=".test.TestActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

@ -17,7 +17,7 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
int index = 0;
//String URL = "http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk";
//String URL = "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
private final String URL = "ftp://192.168.29.140:21/download//AriaPrj.rar";
private final String URL = "ftp://192.168.29.140:21/download/AriaPrj.rar";
//String URL = "https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe";
@Override protected int setLayoutId() {

@ -95,7 +95,7 @@ public class AnyRunnModule {
.loadFtp(url)
.login("lao", "123456")
//.addHeader("Accept-Encoding", "gzip")
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/ftp_ggsg16.apk")
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/")
//.resetState()
.start();
//String[] urls = new String[] {

@ -21,9 +21,9 @@ public class TestActivity extends BaseActivity<ActivityTestBinding> {
String TAG = "TestActivity";
//String URL = "http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载
//private final String URL = "ftp://192.168.1.3:21/download//AriaPrj.rar";
private final String FILE_PATH = "/mnt/sdcard/SDK_Demo-release.apk";
private final String FILE_PATH = "/mnt/sdcard/AriaPrj.rar";
//private final String URL = "ftp://192.168.29.140:21/aa//你好";
private final String URL = "http://192.168.29.140:5000/upload/";
private final String URL = "ftp://192.168.29.140:21/upload/";
@Override protected int setLayoutId() {
return R.layout.activity_test;
@ -76,18 +76,17 @@ public class TestActivity extends BaseActivity<ActivityTestBinding> {
switch (view.getId()) {
case R.id.start:
Aria.upload(this)
.load(FILE_PATH)
.loadFtp(FILE_PATH)
.login("lao", "123456")
.setUploadUrl(URL)
.setRequestMode(RequestEnum.POST)
.setExtendField("韩寒哈大双")
.setAttachment("file")
.start();
break;
case R.id.stop:
Aria.upload(this).load(FILE_PATH).stop();
Aria.upload(this).loadFtp(FILE_PATH).stop();
break;
case R.id.cancel:
Aria.upload(this).load(FILE_PATH).cancel();
Aria.upload(this).loadFtp(FILE_PATH).cancel();
break;
}
}

Loading…
Cancel
Save