Fixed partitioning

This commit is contained in:
M66B 2020-01-27 13:12:57 +01:00
parent aed50fa559
commit 8d73342363
1 changed files with 10 additions and 11 deletions

View File

@ -64,7 +64,6 @@ import java.util.Hashtable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.TreeMap;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import javax.mail.AuthenticationFailedException; import javax.mail.AuthenticationFailedException;
@ -1122,16 +1121,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
db.operation().liveOperations(folder.id).observe(cowner, new Observer<List<TupleOperationEx>>() { db.operation().liveOperations(folder.id).observe(cowner, new Observer<List<TupleOperationEx>>() {
private List<Long> handling = new ArrayList<>(); private List<Long> handling = new ArrayList<>();
private final Map<TupleOperationEx.PartitionKey, List<TupleOperationEx>> partitions = new HashMap<>();
private final Map<TupleOperationEx.PartitionKey, List<TupleOperationEx>> partitions =
new TreeMap<>(new Comparator<TupleOperationEx.PartitionKey>() {
@Override
public int compare(TupleOperationEx.PartitionKey k1, TupleOperationEx.PartitionKey k2) {
Integer p1 = k1.getPriority();
Integer p2 = k2.getPriority();
return p1.compareTo(p2);
}
});
private final PowerManager.WakeLock wlFolder = pm.newWakeLock( private final PowerManager.WakeLock wlFolder = pm.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":folder." + folder.id); PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":folder." + folder.id);
@ -1168,6 +1158,15 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
} }
} }
Collections.sort(keys, new Comparator<TupleOperationEx.PartitionKey>() {
@Override
public int compare(TupleOperationEx.PartitionKey k1, TupleOperationEx.PartitionKey k2) {
Integer p1 = k1.getPriority();
Integer p2 = k2.getPriority();
return p1.compareTo(p2);
}
});
for (TupleOperationEx.PartitionKey key : keys) { for (TupleOperationEx.PartitionKey key : keys) {
synchronized (partitions) { synchronized (partitions) {
Log.i(folder.name + Log.i(folder.name +