From 5d1cababc6a76d4d192055fbcf1ae572a15529ab Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Mon, 15 Sep 2014 18:02:45 +0200 Subject: [PATCH] Added optimization: don't to the single deletion if we have purged the DB before, it's useless --- db/smsmapper.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/db/smsmapper.php b/db/smsmapper.php index c81f1ca..ef13363 100644 --- a/db/smsmapper.php +++ b/db/smsmapper.php @@ -50,13 +50,16 @@ class SmsMapper extends Mapper { $sms["seen"] === "true" ? "1" : "0" ); - // Remove previous record - // @ TODO: only update the required fields, getAllIds can be useful - $query = \OC_DB::prepare('DELETE FROM *PREFIX*ocsms_smsdatas ' . - 'WHERE user_id = ? AND sms_id = ?'); - $result = $query->execute(array( - $userId, (int) $sms["_id"] - )); + // Only delete if we haven't purged the DB + if ($purgeAllSmsBeforeInsert === false) { + // Remove previous record + // @ TODO: only update the required fields, getAllIds can be useful + $query = \OC_DB::prepare('DELETE FROM *PREFIX*ocsms_smsdatas ' . + 'WHERE user_id = ? AND sms_id = ?'); + $result = $query->execute(array( + $userId, (int) $sms["_id"] + )); + } $query = \OC_DB::prepare('INSERT INTO *PREFIX*ocsms_smsdatas ' . '(user_id, added, lastmodified, sms_flags, sms_date, sms_id,' .