imap-backup 14.4.5 → 14.5.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 +4 -4
- data/README.md +1 -1
- data/imap-backup.gemspec +1 -1
- data/lib/imap/backup/account/local_only_folder_deleter.rb +1 -1
- data/lib/imap/backup/account/serialized_folders.rb +27 -1
- data/lib/imap/backup/account.rb +19 -7
- data/lib/imap/backup/cli/local.rb +1 -1
- data/lib/imap/backup/cli/utils.rb +1 -1
- data/lib/imap/backup/email/provider/base.rb +1 -3
- data/lib/imap/backup/serializer/imap.rb +1 -0
- data/lib/imap/backup/serializer/mbox.rb +1 -0
- data/lib/imap/backup/serializer.rb +42 -2
- data/lib/imap/backup/thunderbird/mailbox_exporter.rb +1 -1
- data/lib/imap/backup/version.rb +2 -2
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ff8bf4fdd37e57e1fd9cef8abc4485813eeb48752768a3f463df3afac3dc4d6
|
4
|
+
data.tar.gz: 831899f082fff0997acd46d1e341004ac43cf53a2883358e67ab095b88a26bf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d826d98de67625935c73a0ae01f2896717428dc3357ba899f5edee47a8b458064c932eea98a7331b0c6678f233329ae71001d7038cfaf1dd22aa5ea5f19d723e
|
7
|
+
data.tar.gz: 9570a8070e6ab390c65dfb1a395a69f5b26aa501a777acb8e1cd58956adddd76b0c6e6bdd828b26f29c375ff671adcb31a91fdd85839be363d99179bea92bf9f
|
data/README.md
CHANGED
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", "
|
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.
|
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
|
data/lib/imap/backup/account.rb
CHANGED
@@ -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 =
|
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
|
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
|
@@ -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.
|
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
|
-
|
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?
|
@@ -28,7 +28,41 @@ module Imap::Backup
|
|
28
28
|
extend Forwardable
|
29
29
|
|
30
30
|
def_delegator :mbox, :pathname, :mbox_pathname
|
31
|
-
|
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
|
-
|
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
|
|
data/lib/imap/backup/version.rb
CHANGED
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
|
+
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:
|
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.
|
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.
|
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.
|
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: []
|