afreakyelf / Pdf-Viewer

A Lightweight PDF Viewer Android library which only occupies around 80kb while most of the Pdf viewer occupies up to 16MB space.
https://afreakyelf.github.io/Pdf-Viewer/
MIT License
821 stars 173 forks source link

[BUG] Broken download of cached file #156

Open FrancisDx opened 2 months ago

FrancisDx commented 2 months ago

📝 Describe the Bug

The file cannot be downloaded if it is loaded from the cache.

📖 Library Version

🚶 Steps to Reproduce

Please follow these steps to reproduce the issue:

  1. show pdf from url (PdfViewerActivity.launchPdfFromUrl)
  2. show pdf from url (PdfViewerActivity.launchPdfFromUrl) again (so pdf is loaded instantly from cache)
  3. Unexpected Behavior: on download icon click, file is not asking for a location, but the "File not downloaded yet" toast is shown.
  4. Relevant Code/Stack Trace: Actually the cache path "pdfcache___" is not used, the file is cached to the apps cacheDir.

🤔 Expected Behavior

download from cache as well.

💬 Additional Context

temp workaroud: delete cached pdf before opening PdfViewerActivity: context?.cacheDir?.listFiles { _, name -> name.endsWith(".pdf") }?.forEach { it.delete() }


github-actions[bot] commented 2 months ago

Thank you for creating your first issue. We appreciate your help in making this project better. We will look into it, and get back to you soon. Need help or want to discuss this issue? Join our Discord community here to ask questions and discuss this issue live!