imap-backup 14.4.5 → 14.5.1

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: e492fd50201bbf2424231905b4cdb6fe3d44d99fa446c624b851c9ef50eb686f
4
- data.tar.gz: e2ed159ec5e92e7d97a685093456491afe94d34e70702d4e7a0449cf150009dd
3
+ metadata.gz: 7ff8bf4fdd37e57e1fd9cef8abc4485813eeb48752768a3f463df3afac3dc4d6
4
+ data.tar.gz: 831899f082fff0997acd46d1e341004ac43cf53a2883358e67ab095b88a26bf7
5
5
  SHA512:
6
- metadata.gz: d0f4acc27fa79b789c83298af7788c01e9b8c837aa5086d1675e98b7ef80abd7fe1b3decb4b36c3f586126f7d9dc54499358bc05f7e65e0de3cbc29207233188
7
- data.tar.gz: e036ad78bff71f98012907444f5eb36c56e01f3a3a8d2f37fbb0b06f5c1850eaddd26a4be86a8581a8f25e322731eac06a25a18853ac4433a2793cbd603b8727
6
+ metadata.gz: d826d98de67625935c73a0ae01f2896717428dc3357ba899f5edee47a8b458064c932eea98a7331b0c6678f233329ae71001d7038cfaf1dd22aa5ea5f19d723e
7
+ data.tar.gz: 9570a8070e6ab390c65dfb1a395a69f5b26aa501a777acb8e1cd58956adddd76b0c6e6bdd828b26f29c375ff671adcb31a91fdd85839be363d99179bea92bf9f
data/README.md CHANGED
@@ -63,7 +63,7 @@ $ rspec
63
63
  To exclude container-based tests
64
64
 
65
65
  ```sh
66
- $ rspec --tag ~docker
66
+ $ rspec --tag ~container
67
67
  ```
68
68
 
69
69
  To run **just** the feature specs
data/imap-backup.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
27
27
  gem.add_runtime_dependency "os"
28
28
  gem.add_runtime_dependency "rake"
29
29
  gem.add_runtime_dependency "thor", "~> 1.1"
30
- gem.add_runtime_dependency "thunderbird", ">= 0.0.0"
30
+ gem.add_runtime_dependency "thunderbird", "0.3.0"
31
31
 
32
32
  gem.metadata = {
33
33
  "rubygems_mfa_required" => "true"
@@ -22,7 +22,7 @@ module Imap::Backup
22
22
  )
23
23
  wanted = backup_folders.map(&:name)
24
24
  serialized_folders = Account::SerializedFolders.new(account: account)
25
- serialized_folders.each do |serializer, _folder|
25
+ serialized_folders.each_key do |serializer|
26
26
  serializer.delete if !wanted.include?(serializer.folder)
27
27
  end
28
28
  end
@@ -17,7 +17,7 @@ module Imap::Backup
17
17
  @account = account
18
18
  end
19
19
 
20
- # Runs the enumeration
20
+ # Runs the enumeration over local serializers and remote folders
21
21
  # @yieldparam serializer [Serializer] the folder's serializer
22
22
  # @yieldparam folder [Account::Folder] the online folder
23
23
  # @return [void]
@@ -32,6 +32,32 @@ module Imap::Backup
32
32
  end
33
33
  end
34
34
 
35
+ # Runs the enumeration over each local serializer
36
+ # @yieldparam serializer [Serializer] the folder's serializer
37
+ # @return [void]
38
+ def each_key(&block)
39
+ return enum_for(:each_key) if !block
40
+
41
+ glob.each do |path|
42
+ name = path.relative_path_from(base).to_s[0..-6]
43
+ serializer = Serializer.new(account.local_path, name)
44
+ block.call(serializer)
45
+ end
46
+ end
47
+
48
+ # Runs the enumeration over each remote folder
49
+ # @yieldparam folder [Account::Folder] the online folder
50
+ # @return [void]
51
+ def each_value(&block)
52
+ return enum_for(:each_value) if !block
53
+
54
+ glob.each do |path|
55
+ name = path.relative_path_from(base).to_s[0..-6]
56
+ folder = Account::Folder.new(account.client, name)
57
+ block.call(folder)
58
+ end
59
+ end
60
+
35
61
  private
36
62
 
37
63
  attr_reader :account
@@ -42,9 +42,6 @@ module Imap::Backup
42
42
  # The address of the IMAP server
43
43
  # @return [String]
44
44
  attr_reader :server
45
- # Extra options to be passed to the IMAP server when connecting
46
- # @return [Hash, void]
47
- attr_reader :connection_options
48
45
  # The name of the download strategy to adopt during backups
49
46
  # @return [String]
50
47
  attr_accessor :download_strategy
@@ -67,10 +64,11 @@ module Imap::Backup
67
64
  @password = options[:password]
68
65
  @local_path = options[:local_path]
69
66
  @folders = options[:folders]
70
- @folder_blacklist = options[:folder_blacklist]
71
- @mirror_mode = options[:mirror_mode]
67
+ @folder_blacklist = options[:folder_blacklist] || false
68
+ @mirror_mode = options[:mirror_mode] || false
72
69
  @server = options[:server]
73
- @connection_options = options[:connection_options]
70
+ @connection_options = nil
71
+ @supplied_connection_options = options[:connection_options]
74
72
  @download_strategy = options[:download_strategy]
75
73
  @multi_fetch_size_orignal = options[:multi_fetch_size]
76
74
  @reset_seen_flags_after_fetch = options[:reset_seen_flags_after_fetch]
@@ -146,7 +144,7 @@ module Imap::Backup
146
144
  h[:folder_blacklist] = true if @folder_blacklist
147
145
  h[:mirror_mode] = true if @mirror_mode
148
146
  h[:server] = @server if @server
149
- h[:connection_options] = @connection_options if @connection_options
147
+ h[:connection_options] = @connection_options if connection_options
150
148
  h[:multi_fetch_size] = multi_fetch_size
151
149
  if @reset_seen_flags_after_fetch
152
150
  h[:reset_seen_flags_after_fetch] = @reset_seen_flags_after_fetch
@@ -198,8 +196,22 @@ module Imap::Backup
198
196
  update(:server, value)
199
197
  end
200
198
 
199
+ # Extra options to be passed to the IMAP server when connecting
200
+ # @return [Hash, void]
201
+ def connection_options
202
+ @connection_options ||=
203
+ case @supplied_connection_options
204
+ when String
205
+ JSON.parse(@supplied_connection_options, symbolize_names: true)
206
+ else
207
+ @supplied_connection_options
208
+ end
209
+ end
210
+
201
211
  # @return [void]
202
212
  def connection_options=(value)
213
+ # Ensure we've loaded the connection_options
214
+ connection_options
203
215
  parsed =
204
216
  if value == ""
205
217
  nil
@@ -70,7 +70,7 @@ module Imap::Backup
70
70
  list = serialized_folders.map { |_s, f| {name: f.name} }
71
71
  Kernel.puts list.to_json
72
72
  else
73
- serialized_folders.each do |_s, f|
73
+ serialized_folders.each_value do |f|
74
74
  Kernel.puts %("#{f.name}")
75
75
  end
76
76
  end
@@ -84,7 +84,7 @@ module Imap::Backup
84
84
 
85
85
  raise "No serialized folders were found for account '#{email}'" if serialized_folders.none?
86
86
 
87
- serialized_folders.each do |serializer, _folder|
87
+ serialized_folders.each_key do |serializer|
88
88
  Thunderbird::MailboxExporter.new(
89
89
  email, serializer, profile, force: force
90
90
  ).run
@@ -8,9 +8,7 @@ module Imap::Backup
8
8
  class Email::Provider::Base
9
9
  # @return [Hash] defaults for the Net::IMAP connection
10
10
  def options
11
- # rubocop:disable Naming/VariableNumber
12
- {port: 993, ssl: {ssl_version: :TLSv1_2}}
13
- # rubocop:enable Naming/VariableNumber
11
+ {port: 993, ssl: {min_version: OpenSSL::SSL::TLS1_2_VERSION}}
14
12
  end
15
13
 
16
14
  def sets_seen_flags_on_fetch?
@@ -108,6 +108,7 @@ module Imap::Backup
108
108
  def delete
109
109
  return if !exist?
110
110
 
111
+ Logger.logger.info("Deleting metadata file '#{pathname}'")
111
112
  FileUtils.rm(pathname)
112
113
  @loaded = false
113
114
  @messages = nil
@@ -70,6 +70,7 @@ module Imap::Backup
70
70
  def delete
71
71
  return if !exist?
72
72
 
73
+ Logger.logger.info("Deleting mailbox '#{pathname}'")
73
74
  FileUtils.rm(pathname)
74
75
  end
75
76
 
@@ -28,7 +28,41 @@ module Imap::Backup
28
28
  extend Forwardable
29
29
 
30
30
  def_delegator :mbox, :pathname, :mbox_pathname
31
- def_delegators :imap, :get, :messages, :uid_validity, :uids, :update_uid
31
+
32
+ # Get message metadata
33
+ # @param uid [Integer] a message UID
34
+ # @return [Serializer::Message]
35
+ def get(uid)
36
+ validate!
37
+ imap.get(uid)
38
+ end
39
+
40
+ # @return [Array<Hash>]
41
+ def messages
42
+ validate!
43
+ imap.messages
44
+ end
45
+
46
+ # @return [Integer] the UID validity for the folder
47
+ def uid_validity
48
+ validate!
49
+ imap.uid_validity
50
+ end
51
+
52
+ # @return [Array<Integer>] The uids of all messages
53
+ def uids
54
+ validate!
55
+ imap.uids
56
+ end
57
+
58
+ # Update a message's metadata, replacing its UID
59
+ # @param old [Integer] the existing message UID
60
+ # @param new [Integer] the new UID to apply to the message
61
+ # @return [void]
62
+ def update_uid(old, new)
63
+ validate!
64
+ imap.update_uid(old, new)
65
+ end
32
66
 
33
67
  # @return [String] a folder name
34
68
  attr_reader :folder
@@ -62,10 +96,14 @@ module Imap::Backup
62
96
 
63
97
  optionally_migrate2to3
64
98
 
65
- if imap.valid? && mbox.valid?
99
+ imap_valid = imap.valid?
100
+ mbox_valid = mbox.valid?
101
+ if imap_valid && mbox_valid
66
102
  @validated = true
67
103
  return true
68
104
  end
105
+ Logger.logger.info("Metadata file '#{imap.pathname}' is invalid") if !imap_valid
106
+ Logger.logger.info("Mailbox '#{mbox.pathname}' is invalid") if !mbox_valid
69
107
 
70
108
  delete
71
109
 
@@ -247,6 +285,8 @@ module Imap::Backup
247
285
  MESSAGE
248
286
 
249
287
  migrator.run
288
+ # Ensure new metadata gets loaded
289
+ @imap = nil
250
290
  end
251
291
 
252
292
  def ensure_containing_directory
@@ -104,7 +104,7 @@ module Imap::Backup
104
104
  @local_folder ||= begin
105
105
  top_level_folders = [EXPORT_PREFIX, email]
106
106
  prefixed_folder_path = File.join(top_level_folders, serializer.folder)
107
- ::Thunderbird::LocalFolder.new(profile, prefixed_folder_path)
107
+ ::Thunderbird::LocalFolder.new(profile: profile, path: prefixed_folder_path)
108
108
  end
109
109
  end
110
110
 
@@ -4,9 +4,9 @@ module Imap::Backup
4
4
  # @private
5
5
  MAJOR = 14
6
6
  # @private
7
- MINOR = 4
7
+ MINOR = 5
8
8
  # @private
9
- REVISION = 5
9
+ REVISION = 1
10
10
  # @private
11
11
  PRE = nil
12
12
  # The application version
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: 14.4.5
4
+ version: 14.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Yates
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-24 00:00:00.000000000 Z
11
+ date: 2024-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: thunderbird
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.0.0
117
+ version: 0.3.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.0.0
124
+ version: 0.3.0
125
125
  description: Backup GMail, or any other IMAP email service, to disk.
126
126
  email:
127
127
  - joe.g.yates@gmail.com
@@ -218,7 +218,7 @@ licenses:
218
218
  - MIT
219
219
  metadata:
220
220
  rubygems_mfa_required: 'true'
221
- post_install_message:
221
+ post_install_message:
222
222
  rdoc_options: []
223
223
  require_paths:
224
224
  - lib
@@ -233,8 +233,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  - !ruby/object:Gem::Version
234
234
  version: '0'
235
235
  requirements: []
236
- rubygems_version: 3.3.7
237
- signing_key:
236
+ rubygems_version: 3.4.10
237
+ signing_key:
238
238
  specification_version: 4
239
239
  summary: Backup GMail (or other IMAP) accounts to disk
240
240
  test_files: []