imap-backup 4.2.1 → 4.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4acc06bc3ae80d8d4ab9ac5c357ff123e73f2c798d98b94c3e36f3a82daee441
4
- data.tar.gz: 2ca50fa37e148768e73fc91fd4035a691a8d5f6083a702127dc02c8237d64a19
3
+ metadata.gz: 4a03b28188aede7ee27bb741e32a40619a2fe58090631a6341eba5cffc2cefe4
4
+ data.tar.gz: d50ac5b602aa86f150846dc925962f727e1e0bcb830113eace96cec1038833e5
5
5
  SHA512:
6
- metadata.gz: 135e5de500d5d1cae59f43fffe6c412b83d27dd26d96566019912198f13bbeb9784bd76c70ca6524caf85ff917073dc9e6ad7890836d5d9f8f4e5dd3b24cceb2
7
- data.tar.gz: a9941e460943682553a20a32b5b8d497821485fec6971f15389e08359c6f59036ee6545aa5bb83e0326040b574c8a5ee57fa50d13a6011b2594c21945b4c8e95
6
+ metadata.gz: d5b95c61e9f505d63274ba73e50bc7e15cc44b9391e8fc1bc3cc8a70bfb59dd11c43bc41fe0334c70f089ccf15a5890c9ae9d3fe4631062a085a753836fd8f4a
7
+ data.tar.gz: a8657ca4282ea0a6e0037c6dc687265a23f2e0af16146900de9665aaf6a03f118d0895a33ee89a2dc788f0bb358b3651b90ddaf721ba588a949b92acd975781c
@@ -13,31 +13,45 @@ module Imap::Backup
13
13
  def run
14
14
  uids = folder.uids - serializer.uids
15
15
  count = uids.count
16
- Imap::Backup::Logger.logger.debug "[#{folder.name}] #{count} new messages"
16
+ debug "#{count} new messages"
17
17
  uids.each_slice(block_size).with_index do |block, i|
18
- offset = i * block_size + 1
19
18
  uids_and_bodies = folder.fetch_multi(block)
20
19
  if uids_and_bodies.nil?
21
20
  if block_size > 1
22
- Imap::Backup::Logger.logger.debug("[#{folder.name}] Multi fetch failed for UIDs #{block.join(", ")}, switching to single fetches")
21
+ debug("Multi fetch failed for UIDs #{block.join(", ")}, switching to single fetches")
23
22
  @block_size = 1
24
23
  redo
25
24
  else
26
- Imap::Backup::Logger.logger.debug("[#{folder.name}] Fetch failed for UID #{block[0]} - skipping")
25
+ debug("Fetch failed for UID #{block[0]} - skipping")
27
26
  next
28
27
  end
29
28
  end
30
29
 
30
+ offset = i * block_size + 1
31
31
  uids_and_bodies.each.with_index do |uid_and_body, j|
32
32
  uid = uid_and_body[:uid]
33
33
  body = uid_and_body[:body]
34
- Imap::Backup::Logger.logger.debug(
35
- "[#{folder.name}] uid: #{uid} (#{offset +j}/#{count}) - " \
36
- "#{body.size} bytes"
37
- )
38
- serializer.save(uid, body)
34
+ case
35
+ when !body
36
+ info("Fetch returned empty body - skipping")
37
+ when !uid
38
+ info("Fetch returned empty UID - skipping")
39
+ else
40
+ debug("uid: #{uid} (#{offset + j}/#{count}) - #{body.size} bytes")
41
+ serializer.save(uid, body)
42
+ end
39
43
  end
40
44
  end
41
45
  end
46
+
47
+ private
48
+
49
+ def info(message)
50
+ Imap::Backup::Logger.logger.info("[#{folder.name}] #{message}")
51
+ end
52
+
53
+ def debug(message)
54
+ Imap::Backup::Logger.logger.debug("[#{folder.name}] #{message}")
55
+ end
42
56
  end
43
57
  end
@@ -3,7 +3,7 @@ module Imap; end
3
3
  module Imap::Backup
4
4
  MAJOR = 4
5
5
  MINOR = 2
6
- REVISION = 1
6
+ REVISION = 2
7
7
  PRE = nil
8
8
  VERSION = [MAJOR, MINOR, REVISION, PRE].compact.map(&:to_s).join(".")
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imap-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Yates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-25 00:00:00.000000000 Z
11
+ date: 2022-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline