Add utility method to get amount of free space available to device data partition.
This commit is contained in:
parent
22c4e2d084
commit
7f1d59f40a
1 changed files with 10 additions and 0 deletions
|
@ -5,12 +5,15 @@
|
|||
|
||||
package org.thoughtcrime.securesms.backup.v2
|
||||
|
||||
import android.os.Environment
|
||||
import android.os.StatFs
|
||||
import androidx.annotation.WorkerThread
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import okio.ByteString.Companion.toByteString
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.ByteSize
|
||||
import org.signal.core.util.EventTimer
|
||||
import org.signal.core.util.Stopwatch
|
||||
import org.signal.core.util.bytes
|
||||
|
@ -127,6 +130,13 @@ object BackupRepository {
|
|||
}
|
||||
}
|
||||
|
||||
fun getFreeStorageSpace(): ByteSize {
|
||||
val statFs = StatFs(Environment.getDataDirectory().absolutePath)
|
||||
val free = (statFs.availableBlocksLong) * statFs.blockSizeLong
|
||||
|
||||
return free.bytes
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun skipMediaRestore() {
|
||||
// TODO [backups] -- Clear the error as necessary
|
||||
|
|
Loading…
Add table
Reference in a new issue