mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
fix: filter jobs that can be executed with the current factories
This commit is contained in:
parent
32902d5bc8
commit
6db86eb958
@ -90,6 +90,7 @@ public class FastJobStorage implements JobStorage {
|
||||
@Override
|
||||
public synchronized @NonNull List<JobSpec> getPendingJobsWithNoDependenciesInCreatedOrder(long currentTime) {
|
||||
return Stream.of(jobs)
|
||||
.filter(j -> JobManagerFactories.hasFactoryForKey(j.getFactoryKey()))
|
||||
.filterNot(JobSpec::isRunning)
|
||||
.filter(this::firstInQueue)
|
||||
.filter(j -> !dependenciesByJobId.containsKey(j.getId()) || dependenciesByJobId.get(j.getId()).isEmpty())
|
||||
|
@ -20,15 +20,20 @@ import org.thoughtcrime.securesms.loki.protocol.ClosedGroupUpdateMessageSendJob;
|
||||
import org.thoughtcrime.securesms.loki.protocol.ClosedGroupUpdateMessageSendJobV2;
|
||||
import org.thoughtcrime.securesms.loki.protocol.NullMessageSendJob;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class JobManagerFactories {
|
||||
|
||||
private static Collection<String> factoryKeys = new ArrayList<>();
|
||||
|
||||
public static Map<String, Job.Factory> getJobFactories(@NonNull Application application) {
|
||||
return new HashMap<String, Job.Factory>() {{
|
||||
HashMap<String, Job.Factory> factoryHashMap = new HashMap<String, Job.Factory>() {{
|
||||
put(AttachmentDownloadJob.KEY, new AttachmentDownloadJob.Factory());
|
||||
put(AttachmentUploadJob.KEY, new AttachmentUploadJob.Factory());
|
||||
put(AvatarDownloadJob.KEY, new AvatarDownloadJob.Factory());
|
||||
@ -61,6 +66,8 @@ public final class JobManagerFactories {
|
||||
put(PrepareAttachmentAudioExtrasJob.KEY, new PrepareAttachmentAudioExtrasJob.Factory());
|
||||
put(ResetThreadSessionJob.KEY, new ResetThreadSessionJob.Factory());
|
||||
}};
|
||||
factoryKeys.addAll(factoryHashMap.keySet());
|
||||
return factoryHashMap;
|
||||
}
|
||||
|
||||
public static Map<String, Constraint.Factory> getConstraintFactories(@NonNull Application application) {
|
||||
@ -77,4 +84,8 @@ public final class JobManagerFactories {
|
||||
new NetworkConstraintObserver(application),
|
||||
new SqlCipherMigrationConstraintObserver());
|
||||
}
|
||||
|
||||
public static boolean hasFactoryForKey(String factoryKey) {
|
||||
return factoryKeys.contains(factoryKey);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user