Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
修复map长度问题,更新版本至1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Jan 3, 2018
1 parent 89e9bd5 commit 0510ab9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<groupId>lee.study</groupId>
<artifactId>proxyee-down</artifactId>
<version>1.5</version>
<version>1.6</version>

<build>
<plugins>
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/lee/study/down/hanndle/HttpDownInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
"下载响应:" + chunkInfo.getIndex() + "\t" + chunkInfo.getDownSize() + "\t"
+ httpResponse.headers().get(
HttpHeaderNames.CONTENT_RANGE) + "\t" + realContentSize);
FileChannel fileChannel = new RandomAccessFile(taskInfo.buildTaskFilePath(), "rw").getChannel();
FileChannel fileChannel = new RandomAccessFile(taskInfo.buildTaskFilePath(), "rw")
.getChannel();
MappedByteBuffer mappedBuffer = fileChannel.map(MapMode.READ_WRITE,
chunkInfo.getOriStartPosition() + chunkInfo.getDownSize(), chunkInfo.getTotalSize());
chunkInfo.getOriStartPosition() + chunkInfo.getDownSize(),
chunkInfo.getTotalSize() - chunkInfo.getDownSize());
chunkInfo.setStatus(1);
chunkInfo.setFileChannel(fileChannel);
chunkInfo.setMappedBuffer(mappedBuffer);
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/lee/study/down/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@

public class FileUtil {

public static RandomAccessFile getRafFile(String path) throws IOException {
return new RandomAccessFile(path, "rw");
}

/**
* 删除文件或文件夹
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/lee/study/down/util/HttpDownUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public static void safeClose(Channel channel, ChunkInfo chunkInfo) {
}

public static boolean setStatusIfNotDone(ChunkInfo chunkInfo, int update) {
if (chunkInfo.getStatus() != 2 && chunkInfo.getStatus() != update) {
if (chunkInfo.getStatus() != 2) {
chunkInfo.setStatus(update);
return true;
}
Expand Down

0 comments on commit 0510ab9

Please sign in to comment.