mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-29 22:31:06 -05:00
Fix downloads not working for custom SD card paths (closes #3564)
This commit is contained in:
parent
2ef277bcef
commit
ad9f646102
1 changed files with 7 additions and 4 deletions
|
@ -34,11 +34,14 @@ object DiskUtil {
|
||||||
* Gets the available space for the disk that a file path points to, in bytes.
|
* Gets the available space for the disk that a file path points to, in bytes.
|
||||||
*/
|
*/
|
||||||
fun getAvailableStorageSpace(f: UniFile): Long {
|
fun getAvailableStorageSpace(f: UniFile): Long {
|
||||||
val stat = StatFs(f.filePath)
|
val stat = try {
|
||||||
val availBlocks = stat.availableBlocksLong
|
StatFs(f.filePath)
|
||||||
val blockSize = stat.blockSizeLong
|
} catch (_: Exception) {
|
||||||
|
// Assume that exception is thrown when path is on external storage
|
||||||
|
StatFs(Environment.getExternalStorageDirectory().path)
|
||||||
|
}
|
||||||
|
|
||||||
return availBlocks * blockSize
|
return stat.availableBlocksLong * stat.blockSizeLong
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue