Completed and failed downloads incorrectly return downloadItem.state from "in_progress"

I am working on an extension that automatically resumes downloads that were interrupted by inhuman input (such as a network failure). I should note that my custom extension works fine in google chrome. Converting an extension to work with firefox should be simple, but I understand that every download I use in firefox gets stuck in the "in_progress" state (even when it successfully completed, canceled, or crashed) to the download manager.

if((downloadItem.state).localeCompare("interrupted") == 0)
        {
            if(!((downloadItem.error).localeCompare("USER_CANCELED") == 0)
                && !((downloadItem.error).localeCompare("USER_SHUTDOWN") == 0)
            )
            {
                RestartDownload(downloadItem);
            }
        }

is a piece of code that runs in chrome but not firefox. This is because the state is always "in_progress" and never interrupted, even when it is explicitly interrupted in the boot manager. Does anyone else have this problem or is it just me? This is mistake?

+4
source share

Source: https://habr.com/ru/post/1689750/


All Articles