1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00

Rescan categories in small batches to reduce memory usage.

This commit is contained in:
Thomas Tanghus 2012-07-09 00:16:14 +02:00
parent a78b7f6bc8
commit c6326dda76

View File

@ -196,17 +196,20 @@ class OC_Contacts_App {
foreach($vcaddressbooks as $vcaddressbook) {
$vcaddressbookids[] = $vcaddressbook['id'];
}
$vccontacts = OC_Contacts_VCard::all($vcaddressbookids);
$start = 0;
$batchsize = 10;
while($vccontacts = OC_Contacts_VCard::all($vcaddressbookids, $start, $batchsize)){
$cards = array();
foreach($vccontacts as $vccontact) {
$cards[] = $vccontact['carddata'];
}
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', scanning: '.$batchsize.' starting from '.$start,OCP\Util::DEBUG);
// only reset on first batch.
self::getVCategories()->rescan($cards, true, ($start==0?true:false));
$start += $batchsize;
}
}
}
if(is_array($vccontacts) && count($vccontacts) > 0) {
$cards = array();
foreach($vccontacts as $vccontact) {
$cards[] = $vccontact['carddata'];
}
self::$categories->rescan($cards);
}
}
/**