Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always shows "Failed - No File" on Chrome #66

Closed
ccloli opened this issue May 6, 2017 · 3 comments
Closed

Always shows "Failed - No File" on Chrome #66

ccloli opened this issue May 6, 2017 · 3 comments
Labels

Comments

@ccloli
Copy link
Owner

ccloli commented May 6, 2017

Thought mentioned in wiki, that we can try clicking Not download? Click here to download until it gives the file, it seems that it sometimes not working.

lpli0 8wpz ewp 2rbqu8yt

From my recent test, with Chrome 57.0.2987.133, I tried it some times, but it still said "Failed- No File". I also checked my RAM (8GB) usage, only about 66% are used, and from Chrome Blob usage, all of them don't have file data, which likes the Blob storage is used up. This not only happens on Tampermonkey but also Violentmonkey.

Finally I set it always use File System to store files, and it works fine now.

image

I'm not sure if you have this bug or just only me, if you also occurred this problem, please note here, and try my settings.

@ccloli ccloli added the bug label May 6, 2017
@ccloli ccloli changed the title Always show "Failed - No File" on Chrome Always shows "Failed - No File" on Chrome May 6, 2017
@ccloli
Copy link
Owner Author

ccloli commented May 10, 2017

Working on it but still no luck...

(function() {
    'use strict';
    function createBlob(data, config){
        try {
            return new Blob(data, config);
        }
        catch(e){}
    }

    var ab = new ArrayBuffer(10000000);
    var blob = createBlob([ab], {type: 'application/zip'});
    var url = URL.createObjectURL(blob);
    var a = document.createElement('a');
    a.setAttribute('download', 'file');
    a.setAttribute('href', url);
    var clickEvt = new MouseEvent('click');
    a.dispatchEvent(clickEvt);
})();

Here is a script that describes how E-Hentai Downloader gives the file, it works fine on Chrome, or even in Tampermonkey sandbox. I also tried save it with FileSaver.js

(function() {
    'use strict';
    function createBlob(data, config){
        try {
            return new Blob(data, config);
        }
        catch(e){}
    }

    var ab = new ArrayBuffer(10000000);
    var blob = createBlob([ab], {type: 'application/zip'});
    saveAs(blob, 'file')
})();

Both pure browser environment and Tampermonkey are fine, without any warning of "Failed - No File". The same result with JSZip.

Tried exploding the ArrayBuffer data to global variable in E-Hentai Downloader. When downloading, Chrome says "Failed - No File", but when I use the first code to download the ArrayBuffer data that exploded to window, it downloads successful.

Not sure what's up.

@ccloli
Copy link
Owner Author

ccloli commented May 10, 2017

Got it. Here is the problem.

saveAs(blob, fileName + '.zip');

// ...

if ('close' in blob) blob.close();
blob = null;

It seems that on latest Chrome it implements the Blob.close() API. So that when the file is being downloaded, the Blob object has been revoked.

Blob.close()
Closes the blob object, possibly freeing underlying resources.
-- ref: https://developer.mozilla.org/en-US/docs/Web/API/Blob

saveAs(blob, fileName + '.zip');

// ...
setTimeout(function(){
    if ('close' in blob) blob.close();
    blob = null;
}, 1000);

Use a timer will fixed the bug.

@ccloli
Copy link
Owner Author

ccloli commented May 10, 2017

Fixed in 1.26.2, it will delays about 10 seconds to do blob.close(), that should be enough to download a file. If you still have the bug, Not download? Click here to download would really works now :-)

@ccloli ccloli closed this as completed May 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant