Skip to content

Commit

Permalink
fix: the error caused by too large value of subscription information
Browse files Browse the repository at this point in the history
  • Loading branch information
stitchrs committed Feb 27, 2023
1 parent 1d86190 commit 86e94da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ fun Date.format(

fun Long.toBytesString(): String {
return when {
this > 1024.0 * 1024 * 1024 * 1024 * 1024 * 1024 ->
String.format("%.2f EiB", (this.toDouble() / 1024 / 1024 / 1024 / 1024 / 1024 / 1024))
this > 1024.0 * 1024 * 1024 * 1024 * 1024 ->
String.format("%.2f PiB", (this.toDouble() / 1024 / 1024 / 1024 / 1024 / 1024))
this > 1024.0 * 1024 * 1024 * 1024 ->
String.format("%.2f TiB", (this.toDouble() / 1024 / 1024 / 1024 / 1024))
this > 1024 * 1024 * 1024 ->
String.format("%.2f GiB", (this.toDouble() / 1024 / 1024 / 1024))
this > 1024 * 1024 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.FileNotFoundException
import java.math.BigDecimal
import java.util.*

class ProfileManager(private val context: Context) : IProfileManager,
Expand Down Expand Up @@ -159,13 +160,13 @@ class ProfileManager(private val context: Context) : IProfileManager,
val info = flag.split("=")
when {
info[0].contains("upload") -> upload =
info[1].toLong()
BigDecimal(info[1]).longValueExact()

info[0].contains("download") -> download =
info[1].toLong()
BigDecimal(info[1]).longValueExact()

info[0].contains("total") -> total =
info[1].toLong()
info[0].contains("total") -> total =
BigDecimal(info[1]).longValueExact()

info[0].contains("expire") -> {
if (info[1].isNotEmpty()) {
Expand Down

0 comments on commit 86e94da

Please sign in to comment.