clacks 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c26bb094d7008dbb5094d22439e3fc55c75a375
4
- data.tar.gz: b6f54e2f8b485168c67b41b1fc0f5689c9e1e046
3
+ metadata.gz: 8266944afd67107ca0d77a1ddb825c8e3e720ddc
4
+ data.tar.gz: e01a4bb50db6e6f24586e9bd86502375035e4001
5
5
  SHA512:
6
- metadata.gz: d8c93393c43b4a7d19e0829efc1d83e1feecb478e1c34884d178c7bf02a304fa8bb60b3596b2cb7ca35f3d055eb4056763d874ccaca3d7a02f5e24c14e7c62ac
7
- data.tar.gz: 9b102599520b751e9be9093f0ba6c61d2647e6ef3c90a67c95175b9c7c6db6401dfd7c5798ddda0a3894aa2a50f65bf1fe9f5950963668159c09fe2a9a912a16
6
+ metadata.gz: b217905633b1d4f0999004d849cb5dd752d3eb3c15c33800e81a2d4484759b2e909a4b3b63e5f87932fd7cb20bc68e566a4292e7afba69f794d421f5f1681e64
7
+ data.tar.gz: 3cc3bfd8c94890e409f20421a00ddf9aa16568ea2c6994c58c6e87808c998ccb772113abcc946b6d90a0e517e198c73bde462fe7490acec5ecfc52688ca8a41a
@@ -10,17 +10,22 @@ module Clacks
10
10
  # IMAP server timeout: typically after 30 minutes with no activity.
11
11
  # NAT Gateway timeout: typically after 15 minutes with an idle connection.
12
12
  # The solution to this is for the IMAP client to issue a NOOP (No Operation) command
13
- # at intervals, typically every 15 minutes.
14
- IMAP_NOOP_SLEEP = 15 * 60 # 15 minutes
13
+ # at intervals, typically every 12 minutes.
14
+ IMAP_NOOP_SLEEP = 12 * 60 # 12 minutes
15
15
 
16
16
  def run
17
- Clacks.logger.info "Clacks v#{Clacks::VERSION} started"
18
- if Clacks.config[:pop3]
19
- run_pop3
20
- elsif Clacks.config[:imap]
21
- run_imap
22
- else
23
- raise "Either a POP3 or an IMAP server must be configured"
17
+ begin
18
+ Clacks.logger.info "Clacks v#{Clacks::VERSION} started"
19
+ if Clacks.config[:pop3]
20
+ run_pop3
21
+ elsif Clacks.config[:imap]
22
+ run_imap
23
+ else
24
+ raise "Either a POP3 or an IMAP server must be configured"
25
+ end
26
+ rescue Exception => e
27
+ Clacks.logger.error("#{e.message} (#{e.class})\n#{(e.backtrace || []).join("\n")}")
28
+ raise e
24
29
  end
25
30
  end
26
31
 
@@ -103,7 +108,7 @@ module Clacks
103
108
  # reconnect in next loop
104
109
  rescue Net::IMAP::Error, IOError => e
105
110
  # OK: reconnect in next loop
106
- rescue => e
111
+ rescue StandardError => e
107
112
  Clacks.logger.error("#{e.message} (#{e.class})\n#{(e.backtrace || []).join("\n")}")
108
113
  sleep(5) unless stopping?
109
114
  end
@@ -112,14 +117,17 @@ module Clacks
112
117
  end
113
118
 
114
119
  def imap_nooper
115
- @imap_nooper = Thread.new do
120
+ Thread.new do
116
121
  loop do
117
122
  begin
118
123
  sleep IMAP_NOOP_SLEEP
119
124
  @imap.idle_done
120
125
  @imap.noop
121
- rescue
126
+ rescue StandardError
122
127
  # noop
128
+ rescue Exception => e
129
+ Clacks.logger.error("#{e.message} (#{e.class})\n#{(e.backtrace || []).join("\n")}")
130
+ raise e
123
131
  end
124
132
  end
125
133
  end
@@ -147,9 +155,9 @@ module Clacks
147
155
  mail = Mail.new(source)
148
156
  mail.mark_for_delete = true if delete_after_find
149
157
  Clacks.config[:on_mail].call(mail)
150
- rescue Exception => e
151
- Clacks.logger.debug(e.message)
152
- Clacks.logger.debug(e.backtrace)
158
+ rescue StandardError => e
159
+ Clacks.logger.error(e.message)
160
+ Clacks.logger.error(e.backtrace)
153
161
  end
154
162
  begin
155
163
  imap.uid_copy(uid, options[:archivebox]) if options[:archivebox]
@@ -157,7 +165,7 @@ module Clacks
157
165
  expunge = true
158
166
  imap.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED])
159
167
  end
160
- rescue Exception => e
168
+ rescue StandardError => e
161
169
  Clacks.logger.error(e.message)
162
170
  end
163
171
  processed += 1
@@ -185,9 +193,9 @@ module Clacks
185
193
  else
186
194
  begin
187
195
  on_mail.call(mail)
188
- rescue Exception => e
189
- Clacks.logger.debug(e.message)
190
- Clacks.logger.debug(e.backtrace)
196
+ rescue StandardError => e
197
+ Clacks.logger.error(e.message)
198
+ Clacks.logger.error(e.backtrace)
191
199
  end
192
200
  end
193
201
  end
@@ -1,3 +1,3 @@
1
1
  module Clacks
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clacks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITRP
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-24 00:00:00.000000000 Z
11
+ date: 2016-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail