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

fix: multiple file download fix for android #14542

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kuromadara
Copy link

Multiple Photo Download Fix on Mobile App (Android) - #14516

Issue

When downloading photos on the mobile app (Android), multiple taps on the download button result in duplicate downloads of the same file. This creates unnecessary duplicate files with names like foto.jpg, foto (1).jpg, foto (2).jpg, etc.

Root Cause

  • No mechanism to prevent multiple download attempts while a download is in progress
  • File existence checking based only on filename, not content
  • Lack of download state tracking

Changes Made

Download Service ([download.service.dart]

  • Added hash-based file verification using SHA-256
  • Implemented file existence checking using content hash
  • Added methods to calculate and verify file hashes
  • Added logging for download status and skips
  • Prevent redundant downloads of identical content

Download Provider ([download.provider.dart]

  • Added download state tracking mechanism
  • Implemented prevention of concurrent downloads for the same asset
  • Added user feedback through toast messages
  • Enhanced error handling for failed downloads

Dependencies

  • Added crypto: ^3.0.3 package for hash calculation

Testing

  1. Download a photo from the app
  2. Attempt to download the same photo multiple times
  3. Verify that:
    • Only one copy is downloaded
    • User receives appropriate feedback
    • No duplicate files are created
  4. Test with various file types (JPG, HEIC, Live Photos)
  5. Verify hash calculation works correctly for different file sizes

Related Issues

@kuromadara
Copy link
Author

Hey @danieldietzler can you check this and add the label to this.

@kuromadara kuromadara changed the title multiple file download fix for android fix: multiple file download fix for android Dec 11, 2024
Copy link
Author

@kuromadara kuromadara left a comment

Choose a reason for hiding this comment

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

Fixed the dart analysis and pr title error

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

Successfully merging this pull request may close these issues.

Multipiple photo download on mobile app(android).
2 participants