修复ftp文件夹下载失败的问题

v3.6.6
laoyuyu 6 years ago
parent b976348ffe
commit 631017bb67
  1. 3
      Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirDownloadUtil.java
  2. 1
      Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirInfoThread.java
  3. 12
      Aria/src/main/java/com/arialyy/aria/core/download/group/SubDownloadLoader.java
  4. 12
      Aria/src/main/java/com/arialyy/aria/core/inf/ITaskWrapper.java
  5. 1
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/FtpThreadTask.java
  6. 2
      app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java
  7. 2
      app/src/main/java/com/arialyy/simple/download/group/FTPDirDownloadActivity.java
  8. 1
      app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java

@ -23,7 +23,8 @@ import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.exception.BaseException;
/**
* Created by Aria.Lao on 2017/7/27. ftp文件夹下载工具
* Created by Aria.Lao on 2017/7/27.
* ftp文件夹下载工具
*/
public class FtpDirDownloadUtil extends AbsGroupUtil {
private String TAG = "FtpDirDownloadUtil";

@ -69,6 +69,7 @@ class FtpDirInfoThread extends AbsFtpInfoThread<DownloadGroupEntity, DGTaskWrapp
new String(fileName.getBytes(), Charset.forName(mTaskWrapper.asHttp().getCharSet())));
entity.setGroupHash(mEntity.getGroupHash());
entity.setGroupChild(true);
entity.setConvertFileSize(CommonUtil.formatFileSize(ftpFile.getSize()));
entity.setFileSize(ftpFile.getSize());
entity.insert();

@ -23,13 +23,16 @@ import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.downloader.Downloader;
import com.arialyy.aria.core.download.downloader.HttpFileInfoThread;
import com.arialyy.aria.core.inf.AbsTaskWrapper;
import com.arialyy.aria.core.scheduler.ISchedulers;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.util.ALog;
/**
* 子任务下载工具负责创建{@link Downloader}
* 子任务下载负责创建{@link Downloader}
*/
class SubDownloadLoader implements IUtil {
private final String TAG = "SubDownloadLoader";
private Downloader mDownloader;
private DTaskWrapper mWrapper;
@ -88,6 +91,7 @@ class SubDownloadLoader implements IUtil {
}
@Override public void start() {
if (mWrapper.getRequestType() == AbsTaskWrapper.D_HTTP) {
new Thread(new HttpFileInfoThread(mWrapper, new OnFileInfoCallback() {
@Override public void onComplete(String url, CompleteInfo info) {
@ -99,6 +103,12 @@ class SubDownloadLoader implements IUtil {
mSchedulers.obtainMessage(ISchedulers.FAIL, SubDownloadLoader.this);
}
})).start();
} else if (mWrapper.getRequestType() == AbsTaskWrapper.D_FTP) {
mDownloader = new Downloader(mListener, mWrapper);
mDownloader.start();
} else {
ALog.w(TAG, String.format("不识别的类型,requestType:%s", mWrapper.getRequestType()));
}
}
@Override public void resume() {

@ -25,29 +25,29 @@ public interface ITaskWrapper<ENTITY extends AbsEntity> {
/**
* HTTP单任务载
*/
int D_HTTP = 0x11;
int D_HTTP = 1;
/**
* HTTP任务组下载
*/
int DG_HTTP = 0x12;
int DG_HTTP = 2;
/**
* FTP单文件下载
*/
int D_FTP = 0x13;
int D_FTP = 3;
/**
* FTP文件夹下载为避免登录过多子任务由单线程进行处理
*/
int D_FTP_DIR = 0x14;
int D_FTP_DIR = 4;
/**
* HTTP单文件上传
*/
int U_HTTP = 0xA1;
int U_HTTP = 5;
/**
* FTP单文件上传
*/
int U_FTP = 0xA2;
int U_FTP = 6;
ENTITY getEntity();
}

@ -141,7 +141,6 @@ class FtpThreadTask extends AbsFtpThreadTask<UploadEntity, UTaskWrapper> {
* 上传
*
* @return {@code true}上传成功{@code false} 上传失败
* @throws IOException
*/
private boolean upload(final FTPClient client, final BufferedRandomAccessFile bis)
throws IOException {

@ -64,7 +64,7 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
.setFilePath("/mnt/sdcard/").start();
break;
case R.id.stop:
Aria.download(this).loadFtp(URL);
Aria.download(this).loadFtp(URL).stop();
break;
case R.id.cancel:
Aria.download(this).loadFtp(URL).cancel();

@ -35,7 +35,7 @@ import com.arialyy.simple.widget.SubStateLinearLayout;
* Created by lyy on 2017/7/6.
*/
public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBinding> {
private static final String dir = "ftp://192.168.1.2:21/upload/测试";
private static final String dir = "ftp://9.9.9.50:21/upload/测试";
@Bind(R.id.child_list) SubStateLinearLayout mChildList;

@ -43,7 +43,6 @@ public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
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

Loading…
Cancel
Save