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

Improve the download helpers using the Java 7 NIO API. #10248

Merged
merged 4 commits into from
Sep 17, 2023

Conversation

Isira-Seneviratne
Copy link
Member

@Isira-Seneviratne Isira-Seneviratne commented Jul 21, 2023

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • Switch to the desugar_jdk_libs_nio configuration (more information on it can be found here).
  • Use the Java 7 NIO API to improve the download helper classes. The new API offers improved functionality compared to the old File API, including lazy file loading on Android 8.0 and later, and more informative exceptions if something goes wrong. It should be possible to replace the SharpStream interface with SeekableByteChannel in a future PR with this change.
  • The app size is increased by 33 KB with this change.

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

Remove unnecessary else-branch and use Collections.isEmpty().
Add doc comment for splitFilename()
The RuntimeException was not explicitly declared and thus not caught at every call of this constructor. This change ensures that this possible exception is handled by the dedicated error handlers.
Copy link
Member

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

Tested on 21, 26, 33 with SAF enabled and disabled.

@TobiGr TobiGr added downloader Issue is related to the downloader codequality Improvements to the codebase to improve the code quality labels Sep 17, 2023
@sonarcloud
Copy link

sonarcloud bot commented Sep 17, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Isira-Seneviratne Isira-Seneviratne merged commit b1ab261 into TeamNewPipe:dev Sep 17, 2023
5 of 6 checks passed
@Isira-Seneviratne Isira-Seneviratne deleted the NIO_downloads branch September 17, 2023 15:39
@TobiGr TobiGr mentioned this pull request Sep 17, 2023
2 tasks
This was referenced Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codequality Improvements to the codebase to improve the code quality downloader Issue is related to the downloader
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants