<commit_before>/*
 * Copyright (C) 2015 Actor LLC. <https://actor.im>
 */

package im.actor.core.modules.internal.contacts;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import im.actor.core.api.ApiUser;
import im.actor.core.api.rpc.RequestGetContacts;
import im.actor.core.api.rpc.ResponseGetContacts;
import im.actor.core.entity.Contact;
import im.actor.core.entity.User;
import im.actor.core.modules.ModuleContext;
import im.actor.core.modules.utils.ModuleActor;
import im.actor.core.network.RpcCallback;
import im.actor.core.network.RpcException;
import im.actor.runtime.Crypto;
import im.actor.runtime.Log;
import im.actor.runtime.bser.DataInput;
import im.actor.runtime.bser.DataOutput;

public class ContactsSyncActor extends ModuleActor {

    private static final String TAG = "ContactsServerSync";

    private final boolean ENABLE_LOG;

    private ArrayList<Integer> contacts = new ArrayList<Integer>();

    private boolean isInProgress = false;
    private boolean isInvalidated = false;

    public ContactsSyncActor(ModuleContext context) {
        super(context);
        ENABLE_LOG = context.getConfiguration().isEnableContactsLogging();
    }

    @Override
    public void preStart() {
        super.preStart();
        if (ENABLE_LOG) {
            Log.d(TAG, "Loading contacts ids from storage...");
        }
        byte[] data = preferences().getBytes("contact_list");
        if (data != null) {
            try {
                DataInput dataInput = new DataInput(data, 0, data.length);
                int count = dataInput.readInt();
                for (int i = 0; i < count; i++) {
                    contacts.add(dataInput.readInt());
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        notifyState();
        // self().send(new PerformSync());
    }
<commit_msg>fix(core): recover contact sync<commit_after>/*
 * Copyright (C) 2015 Actor LLC. <https://actor.im>
 */

package im.actor.core.modules.internal.contacts;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import im.actor.core.api.ApiUser;
import im.actor.core.api.rpc.RequestGetContacts;
import im.actor.core.api.rpc.ResponseGetContacts;
import im.actor.core.entity.Contact;
import im.actor.core.entity.User;
import im.actor.core.modules.ModuleContext;
import im.actor.core.modules.utils.ModuleActor;
import im.actor.core.network.RpcCallback;
import im.actor.core.network.RpcException;
import im.actor.runtime.Crypto;
import im.actor.runtime.Log;
import im.actor.runtime.bser.DataInput;
import im.actor.runtime.bser.DataOutput;

public class ContactsSyncActor extends ModuleActor {

    private static final String TAG = "ContactsServerSync";

    private final boolean ENABLE_LOG;

    private ArrayList<Integer> contacts = new ArrayList<Integer>();

    private boolean isInProgress = false;
    private boolean isInvalidated = false;

    public ContactsSyncActor(ModuleContext context) {
        super(context);
        ENABLE_LOG = context.getConfiguration().isEnableContactsLogging();
    }

    @Override
    public void preStart() {
        super.preStart();
        if (ENABLE_LOG) {
            Log.d(TAG, "Loading contacts ids from storage...");
        }
        byte[] data = preferences().getBytes("contact_list");
        if (data != null) {
            try {
                DataInput dataInput = new DataInput(data, 0, data.length);
                int count = dataInput.readInt();
                for (int i = 0; i < count; i++) {
                    contacts.add(dataInput.readInt());
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        notifyState();
        self().send(new PerformSync());
    }

{'fraction_non_alphanumeric': 0.115356355620867, 'fraction_numerical': 0.0029390154298310064, 'mean_word_length': 2.8491988689915173, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2022047', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1153, 'n_words': 257}