Skip to content

Add percentage indicator when downloading files/folders - #2

Open
doliosechtra wants to merge 1 commit into
JSleim:mainfrom
doliosechtra:feature/download-percentage
Open

doliosechtra wants to merge 1 commit into
JSleim:mainfrom
doliosechtra:feature/download-percentage

Conversation

@doliosechtra

Copy link
Copy Markdown

Summary

Adds a live percentage indicator for downloads (single file, folder, multi-select).

How it works

  • New streaming pull in handler.py: pull_file_with_progress, pull_dir_with_progress, pull_with_progress via adb exec-out cat with progress_callback(transferred, total, name).
  • Totals from stat -c %s (fallback wc -c) for files and du -sb (fallback du -sk) for folders; unknown sizes fall back to indeterminate + bytes shown.
  • Recursive folder pull recreates empty dirs (find -type d) and streams each file with aggregated progress.
  • Multi-select aggregates totals and reports overall progress + count/N files.

UI

  • DevicePanel._run_progress_modal: determinate QProgressBar with %p%, detail label transferred / total — filename, title shows ... N%.
  • _run_modal (device_panel, explorer, multi_device_window) now listens to WorkerThread.progress_signal.
  • TaskRow shows determinate % in background tasks.
  • Cancel removes the partial file.

Verification

  • py_compile clean.
  • Mocked streaming tests: 1MB file reaches 100%, cancel deletes partial, unknown-size stays indeterminate, multi-file aggregation is monotonic to 100%.
  • Offscreen QApplication smoke test for the progress dialog.

- Stream downloads via adb exec-out cat with transferred/total callbacks
- Support single file, recursive folder (du -sb total), and multi-select aggregated progress
- Determinate progress bar with percent, sizes, and current filename in modal dialogs
- Wire progress_signal through WorkerThread/TaskRow for background tasks
- Cancel removes partial files; unknown sizes fall back to indeterminate

@JSleim JSleim left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, the progress bar is really nice! I pulled the branch and tried it: a ~400 MB file, a folder, a filename with a space, and cancel mid-download (partial file got cleaned up). All worked great.

Two bugs I hit before I can merge:

  1. Files over 2 GB lose the percentage. I made a ~2.2 GB file and the dialog just showed MBs with a busy bar. progress_signal = pyqtSignal(int, int, str) in task_manager.py is 32-bit, so the byte counts wrap negative and the dialog falls back to the "unknown size" display. Changing it to pyqtSignal(object, object, str) should fix it.

  2. A folder with one unreadable subfolder copies as empty but reports success. I made a folder with one readable file and one chmod 000 subfolder. find finds the file but exits non-zero, list_remote_files returns [] on any non-zero exit, and pull_dir_with_progress then returns True. Result: "copied" message, empty folder on the PC. Returning None on failure (for list_remote_files and list_remote_dirs) and treating that as a failed pull would fix it. Even better would be keeping whatever find did output and just warning about the unreadable part, but failing loudly is fine.

Once those two are fixed I’m happy to merge. I’ll follow up myself on a couple of smaller things (keeping modified times, hooking it up to the background task panel), so no need to worry about those.

Happy to help if anything's unclear. Thanks again!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants