Fix issue where we could enqueue unsatisfiable jobs during registration.

This commit is contained in:
Greyson Parrelli
2025-08-12 13:00:06 -04:00
parent b1feffa627
commit 2190a4a58d
2 changed files with 19 additions and 1 deletions

View File

@@ -103,6 +103,10 @@ class JobController {
return;
}
if (chainContainsUnsatisfiableConditions(chain)) {
throw new AssertionError("Unsatisfiable conditions found in job chain!");
}
insertJobChain(chain);
scheduleJobs(chain.get(0));
}
@@ -402,6 +406,20 @@ class JobController {
}
}
@WorkerThread
private boolean chainContainsUnsatisfiableConditions(@NonNull List<List<Job>> chain) {
int firstGlobalPriority = chain.get(0).get(0).getParameters().getGlobalPriority();
for (List<Job> segment : chain) {
for (Job job : segment) {
if (job.getParameters().getGlobalPriority() > firstGlobalPriority) {
return true;
}
}
}
return false;
}
@WorkerThread
private boolean exceedsMaximumInstances(@NonNull Job job) {
boolean exceedsFactory = job.getParameters().getMaxInstancesForFactory() != Job.Parameters.UNLIMITED &&

View File

@@ -878,7 +878,7 @@ class RegistrationViewModel : ViewModel() {
stopwatch.split("account-restore")
AppDependencies.jobManager
.startChain(StorageSyncJob.forRemoteChange())
.startChain(StorageSyncJob.forAccountRestore())
.then(ReclaimUsernameAndLinkJob())
.enqueueAndBlockUntilCompletion(TimeUnit.SECONDS.toMillis(10))
stopwatch.split("storage-sync")