Open Sternbach-Software opened 2 years ago
Hello, as a workaround you can follow what ymqq said in this issue #432 : (also in this article https://blog.csdn.net/Kstar_Ming/article/details/115909863)
public class HotFixedProcessFileStrategy extends ProcessFileStrategy {
@Override
@NonNull
public MultiPointOutputStream createProcessStream(@NonNull DownloadTask task,
@NonNull BreakpointInfo info,
@NonNull DownloadStore store) {
return new HotFixedMultiPointOutputStream(task, info, store);
}
class HotFixedMultiPointOutputStream extends MultiPointOutputStream {
private static final String TAG = "HotFixedMultiPointOutputStream";
private final DownloadTask task;
HotFixedMultiPointOutputStream(@NonNull final DownloadTask task,
@NonNull BreakpointInfo info,
@NonNull DownloadStore store,
@Nullable Runnable syncRunnable) {
super(task, info, store);
this.task = task;
}
public HotFixedMultiPointOutputStream(@NonNull DownloadTask task,
@NonNull BreakpointInfo info,
@NonNull DownloadStore store) {
this(task, info, store, null);
}
@Override
public synchronized void close(int blockIndex) throws IOException {
final DownloadOutputStream outputStream = outputStreamMap.get(blockIndex);
if (outputStream != null) {
outputStream.close();
synchronized (noSyncLengthMap) {
// make sure the length of noSyncLengthMap is equal to outputStreamMap
outputStreamMap.remove(blockIndex);
noSyncLengthMap.remove(blockIndex);
}
}
}
}
}
init singleton instance with the custom strategy
OkDownload.setSingletonInstance(new OkDownload.Builder(context).processFileStrategy(new HotFixedProcessFileStrategy()).build());
To the issue reader :
The close(index)
function and other variables are not public anymore.
For this, create this file under package of same name i.e package com.liulishuo.okdownload.core.file;
OkDownload Version
Sample app included in repository as of April 19, 2022
Problem Describe
Adding this link to the urls array in the sample app bunchactivity.kt on serial mode, I get
java.io.IOException: The current offset on block-info isn't update correct, 53293375 != -1 on 0
. Seems related to #129.Log
There is the whole log from LogCat when I occur the problem(I don't understand how to use okcat. it is not set up in the sample project for me to just run "okcat" from the terminal):