@@ -19,7 +19,19 @@ def initialize(folder, serializer, multi_fetch_size: 1, reset_seen_flags_after_f
19
19
# Runs the downloader
20
20
# @return [void]
21
21
def run
22
- info ( "#{ uids . count } new messages" ) if uids . any?
22
+ debug ( "#{ serializer_uids . count } already messages already downloaded" )
23
+ debug ( "#{ folder_uids . count } messages on server" )
24
+ local_only_count = ( serializer_uids - folder_uids ) . count
25
+ if local_only_count . positive?
26
+ debug ( "#{ local_only_count } downloaded messages no longer on server" )
27
+ end
28
+
29
+ if uids . none?
30
+ debug ( "no new messages on server — skipping" )
31
+ return
32
+ end
33
+
34
+ info ( "#{ uids . count } new messages" )
23
35
24
36
uids . each_slice ( multi_fetch_size ) . with_index do |block , i |
25
37
multifetch_failed = download_block ( block , i )
@@ -62,8 +74,8 @@ def download_block(block, index)
62
74
end
63
75
if uids_and_bodies . nil?
64
76
if multi_fetch_size > 1
65
- uids = block . join ( ", " )
66
- debug ( "Multi fetch failed for UIDs #{ uids } , switching to single fetches" )
77
+ uid_list = block . join ( ", " )
78
+ debug ( "Multi fetch failed for UIDs #{ uid_list } , switching to single fetches" )
67
79
return true
68
80
else
69
81
debug ( "Fetch failed for UID #{ block [ 0 ] } - skipping" )
@@ -96,8 +108,16 @@ def handle_uid_and_body(uid_and_body, index)
96
108
error ( e )
97
109
end
98
110
111
+ def folder_uids
112
+ @folder_uids ||= folder . uids
113
+ end
114
+
115
+ def serializer_uids
116
+ @serializer_uids ||= serializer . uids
117
+ end
118
+
99
119
def uids
100
- @uids ||= folder . uids - serializer . uids
120
+ @uids ||= folder_uids - serializer_uids
101
121
end
102
122
103
123
def debug ( message )
0 commit comments