Restrict Checker.concurrencyLimit to 3 when backend requires network
This commit is contained in:
parent
166f81b3a8
commit
45d710270a
3 changed files with 8 additions and 2 deletions
|
@ -43,6 +43,7 @@ class BackendManager(
|
|||
return mBackendProperties
|
||||
}
|
||||
val isOnRemovableDrive: Boolean get() = backendProperties?.isUsb == true
|
||||
val requiresNetwork: Boolean get() = backendProperties?.requiresNetwork == true
|
||||
|
||||
init {
|
||||
when (settingsManager.storagePluginType) {
|
||||
|
|
|
@ -42,8 +42,8 @@ internal class Checker(
|
|||
private var snapshots: List<Snapshot>? = null
|
||||
private val concurrencyLimit: Int
|
||||
get() {
|
||||
// TODO determine also based on backendManager
|
||||
return Runtime.getRuntime().availableProcessors()
|
||||
val maxConcurrent = if (backendManager.requiresNetwork) 3 else 42
|
||||
return min(Runtime.getRuntime().availableProcessors(), maxConcurrent)
|
||||
}
|
||||
var checkerResult: CheckerResult? = null
|
||||
private set
|
||||
|
|
|
@ -86,6 +86,7 @@ internal class CheckerTest : TransportTest() {
|
|||
fun `check works even with no backup data`() = runBlocking {
|
||||
expectLoadingSnapshots(emptyMap())
|
||||
|
||||
every { backendManager.requiresNetwork } returns Random.nextBoolean()
|
||||
every { nm.onCheckFinishedWithError(0, 0) } just Runs
|
||||
|
||||
assertNull(checker.checkerResult)
|
||||
|
@ -121,6 +122,7 @@ internal class CheckerTest : TransportTest() {
|
|||
snapshotHandle2 to snapshot.copy { token = 2 },
|
||||
)
|
||||
expectLoadingSnapshots(snapshotMap)
|
||||
every { backendManager.requiresNetwork } returns Random.nextBoolean()
|
||||
|
||||
val data = ByteArray(0)
|
||||
coEvery { loader.loadFile(blobHandle1, null) } returns ByteArrayInputStream(data)
|
||||
|
@ -172,6 +174,7 @@ internal class CheckerTest : TransportTest() {
|
|||
},
|
||||
)
|
||||
expectLoadingSnapshots(snapshotMap)
|
||||
every { backendManager.requiresNetwork } returns Random.nextBoolean()
|
||||
|
||||
coEvery { loader.loadFile(blobHandle1, null) } returns ByteArrayInputStream(data1)
|
||||
coEvery { loader.loadFile(blobHandle2, null) } throws GeneralSecurityException()
|
||||
|
@ -220,6 +223,7 @@ internal class CheckerTest : TransportTest() {
|
|||
val expectedSize = blob1.length.toLong() + blob2.length.toLong()
|
||||
|
||||
expectLoadingSnapshots(snapshotMap)
|
||||
every { backendManager.requiresNetwork } returns Random.nextBoolean()
|
||||
|
||||
coEvery { loader.loadFile(blobHandle1, null) } returns ByteArrayInputStream(data1)
|
||||
coEvery { loader.loadFile(blobHandle2, null) } returns ByteArrayInputStream(data2)
|
||||
|
@ -257,6 +261,7 @@ internal class CheckerTest : TransportTest() {
|
|||
},
|
||||
)
|
||||
expectLoadingSnapshots(snapshotMap)
|
||||
every { backendManager.requiresNetwork } returns Random.nextBoolean()
|
||||
|
||||
// only loading app data, not other blobs
|
||||
coEvery { loader.loadFile(appDataBlobHandle1, null) } throws SecurityException()
|
||||
|
|
Loading…
Reference in a new issue