-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 free storage space check for all APIs #10992
Conversation
Tested on Android 7.0 and 7.1.2, works flawless now, thanks! Exception
Crash log
|
It's not a critical check that needs to be perfomed, so in case something does not work on some device/version, let's just ignore the error.
@somos61 thank you for testing, I have no idea why |
app/src/main/java/org/schabi/newpipe/streams/io/StoredDirectoryHelper.java
Outdated
Show resolved
Hide resolved
…yHelper.java Co-authored-by: Tobi <[email protected]>
Quality Gate passedIssues Measures |
dunno why it was 'downloads' instead of 'Download' either, but now dwnl path for SAF is 'content://com.android.providers.downloads.documents/tree/raw:/storage/emulated/0/Download' and downloads ok, for all tested. Thank you |
What is it?
Description of the changes in your PR
The previous code for obtaining free storage space was broken:
SDK_INT
check was before the function call, while another was inside it?)This PR checks for free storage according to https://stackoverflow.com/q/31171838. It uses
Os.statvfs(filePath)
on non-SAF files, andOs.fstatvfs(fileDescriptor)
on SAF files. Note that for SAF files a file descriptor needs to be opened in read mode, but I checked and this does not seem to create a file, and works when the file does not exist (which is basically always the case since it's the file we want to download). Also see https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatvfs.html.I tested on API 22 emulated (both SAF and non-SAF), API 33 emulated (SAF), API 33 device (SAF) and checked the actual values returned by
getFreeStorageSpace()
both on sdcard and internal storage, and everything was correct.Fixes the following issue(s)
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