增加获取执行中的任务api

增加获取剩余时间的api
修复重构loader导致的m3u8问题
This commit is contained in:
laoyuyu
2020-01-07 21:56:35 +08:00
parent b1a2f232fa
commit 432ae1c145
37 changed files with 495 additions and 128 deletions

View File

@@ -42,7 +42,7 @@ public final class FtpDLoaderUtil extends AbsNormalLoaderUtil {
public LoaderStructure BuildLoaderStructure() {
LoaderStructure structure = new LoaderStructure();
structure.addComponent(new FtpDRecordHandler(getTaskWrapper()))
structure.addComponent(new FtpDRecordHandler((DTaskWrapper) getTaskWrapper()))
.addComponent(new NormalThreadStateManager(getListener()))
.addComponent(new FtpDFileInfoTask((DTaskWrapper) getTaskWrapper()))
.addComponent(new FtpDTTBuilder(getTaskWrapper()));

View File

@@ -60,10 +60,7 @@ final class FtpUFileInfoTask extends AbsFtpInfoTask<UploadEntity, UTaskWrapper>
return;
}
//为了防止编码错乱,需要使用原始字符串
if (files.length == 0) {
handleFile(getRemotePath(), null);
}
handleFile(getRemotePath(), files.length == 0 ? null : files[0]);
int reply = client.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
//服务器上没有该文件路径,表示该任务为新的上传任务

View File

@@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
*/
final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
private String dir, remotePath;
private boolean storeFail = false;
private boolean storeSuccess = false;
private ScheduledThreadPoolExecutor timer;
private FTPClient client = null;
private boolean isTimeOut = true;
@@ -77,7 +77,11 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
file.seek(getThreadRecord().startLocation);
}
boolean complete = upload(file);
if (!complete || getThreadTask().isBreak()) {
if (getThreadTask().isBreak()) {
return;
}
if (!complete){
fail(new AriaIOException(TAG, "ftp文件上传失败"), false);
return;
}
ALog.i(TAG,
@@ -158,12 +162,11 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
private boolean upload(final BufferedRandomAccessFile bis)
throws IOException {
fa = new FtpFISAdapter(bis);
storeFail = false;
storeSuccess = false;
startTimer();
final long fileSize = getThreadConfig().tempFile.length();
try {
ALog.d(TAG, String.format("remotePath: %s", remotePath));
client.storeFile(remotePath, fa, new OnFtpInputStreamListener() {
storeSuccess = client.storeFile(remotePath, fa, new OnFtpInputStreamListener() {
boolean isStoped = false;
@Override public void onFtpInputStream(FTPClient client, long totalBytesTransferred,
@@ -181,7 +184,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
progress(bytesTransferred);
} catch (IOException e) {
e.printStackTrace();
storeFail = true;
storeSuccess = false;
}
}
});
@@ -192,15 +195,11 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
if (e.getMessage().contains("AriaIOException caught while copying")) {
e.printStackTrace();
} else {
fail(new AriaIOException(TAG, msg, e), !storeFail);
fail(new AriaIOException(TAG, msg, e), !storeSuccess);
}
return false;
} finally {
fa.close();
closeClient(client);
}
if (storeFail) {
return false;
}
int reply = client.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
@@ -212,6 +211,6 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
closeClient(client);
return false;
}
return true;
return storeSuccess;
}
}