Skip to content

Commit

Permalink
修复下载完成后UI显示错误的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Mar 29, 2018
1 parent 68f1a65 commit 9e36bd9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,14 @@ public void continueDown()
}

public void close(ChunkInfo chunkInfo) {
close(chunkInfo, false);
}

public void close(ChunkInfo chunkInfo, boolean isDone) {
try {
chunkInfo.setStatus(HttpDownStatus.WAIT);
if (!isDone) {
chunkInfo.setStatus(HttpDownStatus.WAIT);
}
if (!attr.containsKey(chunkInfo.getIndex())) {
return;
}
Expand All @@ -257,18 +263,24 @@ public void close(ChunkInfo chunkInfo) {
}
}

public void close() {
public void close(boolean isDone) {
TaskInfo taskInfo = httpDownInfo.getTaskInfo();
synchronized (taskInfo) {
taskInfo.setStatus(HttpDownStatus.WAIT);
if (!isDone) {
taskInfo.setStatus(HttpDownStatus.WAIT);
}
for (ChunkInfo chunkInfo : httpDownInfo.getTaskInfo().getChunkInfoList()) {
synchronized (chunkInfo) {
close(chunkInfo);
close(chunkInfo, isDone);
}
}
}
}

public void close() {
close(false);
}

public void delete(boolean delFile) throws Exception {
TaskInfo taskInfo = httpDownInfo.getTaskInfo();
//删除任务进度记录文件
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
}
if (isDone(chunkInfo.getDownSize(), httpContent)) {
LOGGER.debug("分段下载完成:channelId[" + ctx.channel().id() + "]\t" + chunkInfo);
bootstrap.close(chunkInfo);
bootstrap.close(chunkInfo, true);
//分段下载完成回调
chunkInfo.setStatus(HttpDownStatus.DONE);
taskInfo.refresh(chunkInfo);
Expand All @@ -108,7 +108,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
//文件下载完成回调
taskInfo.setStatus(HttpDownStatus.DONE);
LOGGER.debug("下载完成:channelId[" + ctx.channel().id() + "]\t" + chunkInfo);
bootstrap.close();
bootstrap.close(true);
if (callback != null) {
callback.onDone(bootstrap.getHttpDownInfo());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package lee.study.down.mvc.controller;

import com.sun.org.apache.bcel.internal.generic.NEW;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
Expand Down

0 comments on commit 9e36bd9

Please sign in to comment.