lingochamp / FileDownloader

Multitask、MultiThread(MultiConnection)、Breakpoint-resume、High-concurrency、Simple to use、Single/NotSingle-process
Apache License 2.0
11.04k stars 2.2k forks source link

Bug in FetchDataTask [1.7.6] #1200

Open mseroczynski opened 5 years ago

mseroczynski commented 5 years ago

I am using BaseDownloadTask and manage queue on my own. Every one of these items is correctly configured NOT TO use multi-connection (because of encryption with FileBufferedOutputStream), even though i can't download them because of below condition:

            if (hostRunnable != null && !isSupportSeek) {
                throw new IllegalAccessException(
                        "can't using multi-download when the output stream can't support seek");
            }

Why using hostRunnable crashes out entire downloading (no multi-connection)? Can this be fixed soon?

rantianhua commented 5 years ago

So you custom OutputStreamCreator and you don't support seek? if so, you need custom a ConnectionCountAdapter and force connection count to 1.

mseroczynski commented 5 years ago

Shouldn't it be logic implemented in library itself?

Are you 100% sure there is nothing to do in library and task should be closed? @rantianhua

rantianhua commented 5 years ago

Oh, sorry with my misoperation. I'm asking you the way you use FileDownloader.

rantianhua commented 5 years ago

So, can you show me how do you custom the OutputStreamCreator?

rantianhua commented 5 years ago

You said:

Every one of these items is correctly configured NOT TO use multi-connection

How do you configure items don't use multi-connection?

mseroczynski commented 5 years ago

I'm using my OutputStreamCreator to encrypt on the fly but aren't you supposed to disable multi connection for all downloads with isSeekable = false?

rantianhua commented 5 years ago

Actually, Filedownloader will use single connection if the output stream doesn't support seek:

    private boolean isMultiConnectionAvailable() {
        //noinspection SimplifiableIfStatement
        if (isResumeAvailableOnDB && model.getConnectionCount() <= 1) {
            return false;
        }

        return acceptPartial && supportSeek && !isChunked;
    }

So, I need the whole FileDownloader log to check what's the problem.

mseroczynski commented 4 years ago
//            if (hostRunnable != null && !isSupportSeek) {
//                throw new IllegalAccessException(
//                        "can't using multi-download when the output stream can't support seek");
//            }

This code breaks it. It throws an exception even though i'm NOT using multi-download.