Skip to content

[BUG] Downloading status forever in offline mode #3821

Open

Description

@jesmrec
  1. Set device to offline
  2. Set an image to download

Current: Downloading... status forever
Expected: Download error view

Samsung A51, Android 12

Activity

  1. modified the milestones: Backlog, 4.7 - Next on Jun 6, 2025
  2. modified the milestones: 4.7 - Current, Backlog on Oct 31, 2025
  3. DeepDiver1975 commented on Jun 29, 2026

    @DeepDiver1975
    Contributor

    Still reproducible — confirmed, with a located cause in the current (WorkManager-based) download path.

    Why it gets stuck

    DownloadFileUseCase.enqueueNewDownload() enqueues the OneTimeWorkRequest with no network Constraints, so the worker runs immediately even with no connectivity. Offline, DownloadFileWorker.downloadFileToTemporalFile() throws NoConnectionWithServerException, and notifyDownloadResult() maps exactly that exception to Result.retry():

    if (throwable is NoConnectionWithServerException) {
        Result.retry()
    } else {
        Result.failure()
    }

    A retrying worker sits in WorkManager's ENQUEUED state during backoff. The UI treats that as "downloading": PENDING_WORK_STATUS = [ENQUEUED, RUNNING, BLOCKED], and GetLiveDataForDownloadingFileUseCase reports any work in those states as an active download. So the file shows Downloading… rather than an error.

    With default exponential backoff the gaps between attempts grow quickly (~30s → minutes → hours), and MAXIMUM_NUMBER_OF_RETRIES = 3, so while the device stays offline the status effectively stays Downloading… indefinitely — matching the report. The expected error view only ever appears once retries are exhausted and a later attempt runs.

    Fix directions

    • Add a NetworkType.CONNECTED constraint to the download work request so an offline download stays in a clearly-distinct waiting/blocked presentation instead of masquerading as in-progress; and/or
    • Stop returning Result.retry() for NoConnectionWithServerException (or cap/shorten backoff) so offline downloads surface the download-error view as expected.

    Files: owncloudApp/.../usecases/transfers/downloads/DownloadFileUseCase.kt, owncloudApp/.../workers/DownloadFileWorker.kt, owncloudApp/.../extensions/WorkManagerExt.kt.

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions