Skip to content

Commit

Permalink
feat: Implement CompressionTest
Browse files Browse the repository at this point in the history
Change-Id: I38779c6f7f8c0859ec1a52785726fb16880a7eab
  • Loading branch information
XayahSuSuSu committed Dec 3, 2023
1 parent 26beefb commit 08a3d15
Showing 1 changed file with 33 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import com.xayah.core.datastore.readBackupUserId
import com.xayah.core.datastore.readCleanRestoring
import com.xayah.core.datastore.readCompatibleMode
import com.xayah.core.datastore.readCompressionTest
import com.xayah.core.datastore.readCompressionType
import com.xayah.core.datastore.readFollowSymlinks
import com.xayah.core.datastore.readRestoreUserId
Expand Down Expand Up @@ -66,17 +67,23 @@ class PackagesBackupUtil @Inject constructor(
var input: List<String>
val out = mutableListOf<String>()

Tar.test(src = src, extra = compressionType.decompressPara)
.also { result ->
code = result.code
input = result.input
if (result.isSuccess.not()) {
out.add(log { "$src is broken, trying to delete it." })
rootService.deleteRecursively(src)
} else {
out.add(log { "$src is tested well." })
if (context.readCompressionTest().first()) {
Tar.test(src = src, extra = compressionType.decompressPara)
.also { result ->
code = result.code
input = result.input
if (result.isSuccess.not()) {
out.add(log { "$src is broken, trying to delete it." })
rootService.deleteRecursively(src)
} else {
out.add(log { "Everything seems fine." })
}
}
}
} else {
code = 0
input = listOf()
out.add(log { "Skip testing." })
}

ShellResult(code = code, input = input, out = out)
}
Expand Down Expand Up @@ -467,17 +474,23 @@ class MediumBackupUtil @Inject constructor(
var input: List<String>
val out = mutableListOf<String>()

Tar.test(src = src, extra = compressionType.decompressPara)
.also { result ->
code = result.code
input = result.input
if (result.isSuccess.not()) {
out.add(log { "$src is broken, trying to delete it." })
rootService.deleteRecursively(src)
} else {
out.add(log { "$src is tested well." })
if (context.readCompressionTest().first()) {
Tar.test(src = src, extra = compressionType.decompressPara)
.also { result ->
code = result.code
input = result.input
if (result.isSuccess.not()) {
out.add(log { "$src is broken, trying to delete it." })
rootService.deleteRecursively(src)
} else {
out.add(log { "Everything seems fine." })
}
}
}
} else {
code = 0
input = listOf()
out.add(log { "Skip testing." })
}

ShellResult(code = code, input = input, out = out)
}
Expand Down

0 comments on commit 08a3d15

Please sign in to comment.