Skip to content

Download failing immediately doesn't update UI #94

@Chralu

Description

@Chralu

Describe the bug

When requesting a download that immediately fails, UI stays stucked on the "download in progress" state.

It might happen using iOS when episode URLs are non-SSL http://.
There might be other cases where download fails as soon as it starts.

To Reproduce

  1. Using iOS
  2. add the following podcast : https://feeds.feedburner.com/LaperoDuCaptain
  3. request any episode download.
  4. Episode in list keeps displayed as a download in progress. But download is actually stopped because OS refused http request.

Analyse

mobile_download_service.dart

  @override
  Future<bool> downloadEpisode(Episode episode) async {
 // ....
        final taskId = await downloadManager.enqueueTask(episode.contentUrl, downloadPath, filename);

        // Update the episode with download data
        episode.filepath = episodePath;
        episode.filename = filename;
        episode.downloadTaskId = taskId;
        episode.downloadState = DownloadState.downloading;
        episode.downloadPercentage = 0;

        await repository.saveEpisode(episode);
// ...
  }

Starting a download sequentially :

  1. Enqueues a download task in FlutterDownloader
  2. Gets the FlutterDownloader task id -> persists it in sembast Episode.downloadTaskId
  3. On download update, DownloadService
    1. looks for matching Episode.downloadTaskId in Sembast
    2. If episode is found, it is updated with new download progress.

In the case where download immediately fails, the download status changes before step 2. is done.
Then, a download update event arrives but DownloadService is unable to find the matching Episode in sembast.
=> Sembast episode is not updated
=> Repository.episodeListener is not updated
=> PodcastBloc is not updated

Screenshots

download_fail2.mp4

Smartphone (please complete the following information):

  • Device: iPhone11
  • OS: iOS 16

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingiosIssue only affects or occurs most frequently on iOS

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions