From c49579efcd666579f5522301a593758b717c29f0 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 20:00:08 +0100 Subject: [PATCH] Attemps to fix possible race condition in setArea(). #1342 --- lib/$.coffee | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/$.coffee b/lib/$.coffee index 85e418aca..35d62a4c1 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -271,13 +271,16 @@ $.set = do -> timeout = {} setArea = (area) -> - return if !Object.keys(items[area]).length or timeout[area] - chrome.storage[area].set items[area], -> + data = items[area] + return if !Object.keys(data).length or timeout[area] + items[area] = {} + chrome.storage[area].set data, -> if chrome.runtime.lastError c.error chrome.runtime.lastError.message + for key, val of data when key not of items[area] + items[area][key] = val timeout[area] = setTimeout setArea, $.MINUTE, area return - items[area] = {} delete timeout[area] setAll = $.debounce $.SECOND, ->