diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-07-09 00:16:14 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-07-09 00:16:14 +0200 |
commit | 47aaca49a11997ed2d0d6a92df730f42df77d88c (patch) | |
tree | d1199b75467ed952fe2e05df603781d03ce11ad1 /apps | |
parent | d1cf787197c4a5209881f61c60a9172d7b41a684 (diff) | |
download | nextcloud-server-47aaca49a11997ed2d0d6a92df730f42df77d88c.tar.gz nextcloud-server-47aaca49a11997ed2d0d6a92df730f42df77d88c.zip |
Rescan categories in small batches to reduce memory usage.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/contacts/lib/app.php | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php index 25461877e62..f125ec0293c 100644 --- a/apps/contacts/lib/app.php +++ b/apps/contacts/lib/app.php @@ -196,16 +196,19 @@ class OC_Contacts_App { foreach($vcaddressbooks as $vcaddressbook) { $vcaddressbookids[] = $vcaddressbook['id']; } - $vccontacts = OC_Contacts_VCard::all($vcaddressbookids); - } - } - if(is_array($vccontacts) && count($vccontacts) > 0) { - $cards = array(); - foreach($vccontacts as $vccontact) { - $cards[] = $vccontact['carddata']; + $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; + } } - - self::$categories->rescan($cards); } } |