From 3072550cdbaa174b6dddb56fcc95cbf047947e0e Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 24 Jan 2018 16:49:35 -0800 Subject: [PATCH] Do not save captchas to disk or share them between tabs. They are too short-lived to be worth it now. This should reduce associated I/O errors. --- src/Posting/Captcha.cache.coffee | 14 -------------- src/platform/$.coffee | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/Posting/Captcha.cache.coffee b/src/Posting/Captcha.cache.coffee index 8d38ae193..bbd20657f 100644 --- a/src/Posting/Captcha.cache.coffee +++ b/src/Posting/Captcha.cache.coffee @@ -1,9 +1,5 @@ Captcha.cache = init: -> - $.get 'captchas', [], ({captchas}) => - @sync captchas - @clear() - $.sync 'captchas', @sync.bind(@) $.on d, 'SaveCaptcha', (e) => @save e.detail @@ -19,38 +15,28 @@ Captcha.cache = QR.posts.length > 1 or Conf['Auto-load captcha'] or QR.posts[0].com or QR.posts[0].file ) - sync: (captchas=[]) -> - captchas = [] unless captchas instanceof Array - @captchas = captchas - @count() - getOne: (isReply) -> @clear() i = @captchas.findIndex((x) -> isReply or !x.challenge?) if i >= 0 captcha = @captchas.splice(i, 1)[0] - $.set 'captchas', @captchas @count() captcha else null save: (captcha) -> - $.forceSync 'captchas' @captchas.push captcha @captchas.sort (a, b) -> a.timeout - b.timeout - $.set 'captchas', @captchas @count() clear: -> - $.forceSync 'captchas' if @captchas.length now = Date.now() for captcha, i in @captchas break if captcha.timeout > now if i @captchas = @captchas[i..] - $.set 'captchas', @captchas @count() count: -> diff --git a/src/platform/$.coffee b/src/platform/$.coffee index ad866219c..d9db41d88 100644 --- a/src/platform/$.coffee +++ b/src/platform/$.coffee @@ -664,7 +664,7 @@ else # XXX https://github.com/greasemonkey/greasemonkey/issues/2033 # Also support case where GM_listValues is not defined. $.delete Object.keys(Conf) - $.delete ['previousversion', 'QR Size', 'captchas', 'QR.persona', 'hiddenPSA'] + $.delete ['previousversion', 'QR Size', 'QR.persona', 'hiddenPSA'] try $.delete $.listValues().map (key) -> key.replace g.NAMESPACE, '' cb?()