imap-backup 6.0.0.rc2 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/imap-backup.gemspec +5 -1
- data/lib/cli_coverage.rb +11 -11
- data/lib/email/provider/apple_mail.rb +4 -0
- data/lib/email/provider/base.rb +6 -0
- data/lib/email/provider/purelymail.rb +11 -0
- data/lib/email/provider/unknown.rb +2 -0
- data/lib/email/provider.rb +5 -0
- data/lib/imap/backup/account/connection/backup_folders.rb +27 -0
- data/lib/imap/backup/account/connection/client_factory.rb +55 -0
- data/lib/imap/backup/account/connection/folder_names.rb +26 -0
- data/lib/imap/backup/account/connection.rb +16 -96
- data/lib/imap/backup/account/folder.rb +31 -9
- data/lib/imap/backup/account.rb +15 -6
- data/lib/imap/backup/cli/backup.rb +1 -3
- data/lib/imap/backup/cli/helpers.rb +24 -22
- data/lib/imap/backup/cli/local.rb +20 -13
- data/lib/imap/backup/cli/migrate.rb +4 -10
- data/lib/imap/backup/cli/restore.rb +8 -7
- data/lib/imap/backup/cli/setup.rb +10 -8
- data/lib/imap/backup/cli/stats.rb +78 -0
- data/lib/imap/backup/cli/status.rb +2 -2
- data/lib/imap/backup/cli/utils.rb +4 -6
- data/lib/imap/backup/cli.rb +24 -3
- data/lib/imap/backup/configuration.rb +9 -11
- data/lib/imap/backup/downloader.rb +75 -31
- data/lib/imap/backup/migrator.rb +5 -5
- data/lib/imap/backup/sanitizer.rb +3 -2
- data/lib/imap/backup/serializer/appender.rb +49 -0
- data/lib/imap/backup/serializer/imap.rb +27 -3
- data/lib/imap/backup/serializer/mbox.rb +18 -2
- data/lib/imap/backup/serializer/message_enumerator.rb +29 -0
- data/lib/imap/backup/serializer/unused_name_finder.rb +25 -0
- data/lib/imap/backup/serializer.rb +64 -84
- data/lib/imap/backup/setup/account/header.rb +81 -0
- data/lib/imap/backup/setup/account.rb +28 -91
- data/lib/imap/backup/setup/asker.rb +4 -15
- data/lib/imap/backup/setup/backup_path.rb +45 -0
- data/lib/imap/backup/setup/email.rb +45 -0
- data/lib/imap/backup/setup/folder_chooser.rb +3 -3
- data/lib/imap/backup/setup/helpers.rb +1 -1
- data/lib/imap/backup/setup.rb +7 -6
- data/lib/imap/backup/thunderbird/mailbox_exporter.rb +39 -20
- data/lib/imap/backup/uploader.rb +46 -8
- data/lib/imap/backup/utils.rb +1 -1
- data/lib/imap/backup/version.rb +2 -2
- data/lib/imap/backup.rb +0 -1
- metadata +32 -134
- data/spec/features/backup_spec.rb +0 -100
- data/spec/features/configuration/minimal_configuration.rb +0 -15
- data/spec/features/configuration/missing_configuration.rb +0 -14
- data/spec/features/folders_spec.rb +0 -36
- data/spec/features/helper.rb +0 -2
- data/spec/features/local/list_accounts_spec.rb +0 -12
- data/spec/features/local/list_emails_spec.rb +0 -21
- data/spec/features/local/list_folders_spec.rb +0 -21
- data/spec/features/local/show_an_email_spec.rb +0 -34
- data/spec/features/migrate_spec.rb +0 -35
- data/spec/features/remote/list_account_folders_spec.rb +0 -16
- data/spec/features/restore_spec.rb +0 -162
- data/spec/features/status_spec.rb +0 -43
- data/spec/features/support/aruba.rb +0 -78
- data/spec/features/support/backup_directory.rb +0 -43
- data/spec/features/support/email_server.rb +0 -110
- data/spec/features/support/shared/connection_context.rb +0 -14
- data/spec/features/support/shared/message_fixtures.rb +0 -16
- data/spec/fixtures/connection.yml +0 -7
- data/spec/spec_helper.rb +0 -15
- data/spec/support/fixtures.rb +0 -11
- data/spec/support/higline_test_helpers.rb +0 -8
- data/spec/support/silence_logging.rb +0 -7
- data/spec/unit/email/mboxrd/message_spec.rb +0 -177
- data/spec/unit/email/provider/apple_mail_spec.rb +0 -7
- data/spec/unit/email/provider/base_spec.rb +0 -11
- data/spec/unit/email/provider/fastmail_spec.rb +0 -7
- data/spec/unit/email/provider/gmail_spec.rb +0 -7
- data/spec/unit/email/provider_spec.rb +0 -27
- data/spec/unit/imap/backup/account/connection_spec.rb +0 -433
- data/spec/unit/imap/backup/account/folder_spec.rb +0 -261
- data/spec/unit/imap/backup/account_spec.rb +0 -246
- data/spec/unit/imap/backup/cli/accounts_spec.rb +0 -58
- data/spec/unit/imap/backup/cli/backup_spec.rb +0 -19
- data/spec/unit/imap/backup/cli/folders_spec.rb +0 -39
- data/spec/unit/imap/backup/cli/helpers_spec.rb +0 -87
- data/spec/unit/imap/backup/cli/local_spec.rb +0 -100
- data/spec/unit/imap/backup/cli/migrate_spec.rb +0 -80
- data/spec/unit/imap/backup/cli/restore_spec.rb +0 -67
- data/spec/unit/imap/backup/cli/setup_spec.rb +0 -17
- data/spec/unit/imap/backup/cli/utils_spec.rb +0 -125
- data/spec/unit/imap/backup/cli_spec.rb +0 -93
- data/spec/unit/imap/backup/client/apple_mail_spec.rb +0 -9
- data/spec/unit/imap/backup/client/default_spec.rb +0 -22
- data/spec/unit/imap/backup/configuration_spec.rb +0 -238
- data/spec/unit/imap/backup/downloader_spec.rb +0 -96
- data/spec/unit/imap/backup/logger_spec.rb +0 -48
- data/spec/unit/imap/backup/migrator_spec.rb +0 -58
- data/spec/unit/imap/backup/sanitizer_spec.rb +0 -42
- data/spec/unit/imap/backup/serializer/directory_spec.rb +0 -37
- data/spec/unit/imap/backup/serializer/imap_spec.rb +0 -218
- data/spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb +0 -45
- data/spec/unit/imap/backup/serializer/mbox_spec.rb +0 -101
- data/spec/unit/imap/backup/serializer_spec.rb +0 -296
- data/spec/unit/imap/backup/setup/account_spec.rb +0 -461
- data/spec/unit/imap/backup/setup/asker_spec.rb +0 -137
- data/spec/unit/imap/backup/setup/connection_tester_spec.rb +0 -51
- data/spec/unit/imap/backup/setup/folder_chooser_spec.rb +0 -146
- data/spec/unit/imap/backup/setup/helpers_spec.rb +0 -15
- data/spec/unit/imap/backup/setup_spec.rb +0 -301
- data/spec/unit/imap/backup/thunderbird/mailbox_exporter_spec.rb +0 -116
- data/spec/unit/imap/backup/uploader_spec.rb +0 -54
- data/spec/unit/imap/backup/utils_spec.rb +0 -92
- data/spec/unit/retry_on_error_spec.rb +0 -34
@@ -12,13 +12,13 @@ module Imap::Backup
|
|
12
12
|
|
13
13
|
def run
|
14
14
|
if connection.nil?
|
15
|
-
|
15
|
+
Logger.logger.warn "Connection failed"
|
16
16
|
highline.ask "Press a key "
|
17
17
|
return
|
18
18
|
end
|
19
19
|
|
20
20
|
if imap_folders.nil?
|
21
|
-
|
21
|
+
Logger.logger.warn "Unable to get folder list"
|
22
22
|
highline.ask "Press a key "
|
23
23
|
return
|
24
24
|
end
|
@@ -90,7 +90,7 @@ module Imap::Backup
|
|
90
90
|
|
91
91
|
def toggle_selection(folder_name)
|
92
92
|
if selected?(folder_name)
|
93
|
-
new_list = account.folders.
|
93
|
+
new_list = account.folders.reject { |f| f[:name] == folder_name }
|
94
94
|
account.folders = new_list
|
95
95
|
else
|
96
96
|
existing = account.folders || []
|
data/lib/imap/backup/setup.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "highline"
|
2
2
|
|
3
|
+
require "email/provider"
|
3
4
|
require "imap/backup/account"
|
4
5
|
require "imap/backup/setup/helpers"
|
5
6
|
|
@@ -36,7 +37,7 @@ module Imap::Backup
|
|
36
37
|
config.save
|
37
38
|
throw :done
|
38
39
|
end
|
39
|
-
menu.choice("exit without saving changes")
|
40
|
+
menu.choice("exit without saving changes") { throw :done }
|
40
41
|
else
|
41
42
|
menu.choice("quit") { throw :done }
|
42
43
|
end
|
@@ -67,7 +68,7 @@ module Imap::Backup
|
|
67
68
|
new_setting = !config.debug?
|
68
69
|
menu.choice(menu_item) do
|
69
70
|
config.debug = new_setting
|
70
|
-
|
71
|
+
Logger.setup_logging(config)
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -76,14 +77,14 @@ module Imap::Backup
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def default_account_config(username)
|
79
|
-
|
80
|
+
Imap::Backup::Account.new(
|
80
81
|
username: username,
|
81
82
|
password: "",
|
82
|
-
local_path: File.join(config.path, username.tr("@", "_")),
|
83
83
|
folders: []
|
84
84
|
).tap do |a|
|
85
|
-
|
86
|
-
a.server =
|
85
|
+
provider = ::Email::Provider.for_address(username)
|
86
|
+
a.server = provider.host if provider.host
|
87
|
+
a.reset_seen_flags_after_fetch = true if provider.sets_seen_flags_on_fetch?
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
@@ -21,28 +21,51 @@ module Imap::Backup
|
|
21
21
|
local_folder_ok = local_folder.set_up
|
22
22
|
return false if !local_folder_ok
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
skip_for_msf = check_msf
|
25
|
+
return false if skip_for_msf
|
26
|
+
|
27
|
+
skip_for_local_folder = check_local_folder
|
28
|
+
return false if skip_for_local_folder
|
29
|
+
|
30
|
+
copy_messages
|
31
|
+
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def check_local_folder
|
38
|
+
return false if !local_folder.exists?
|
39
|
+
|
40
|
+
if force
|
41
|
+
Kernel.puts "Overwriting '#{local_folder.path}' as --force option was supplied"
|
42
|
+
return false
|
32
43
|
end
|
33
44
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
45
|
+
Kernel.puts "Skipping export of '#{serializer.folder}' as '#{local_folder.path}' exists"
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
49
|
+
def check_msf
|
50
|
+
return false if !local_folder.msf_exists?
|
51
|
+
|
52
|
+
if force
|
53
|
+
Kernel.puts "Deleting '#{local_folder.msf_path}' as --force option was supplied"
|
54
|
+
File.unlink local_folder.msf_path
|
55
|
+
return false
|
41
56
|
end
|
42
57
|
|
58
|
+
Kernel.puts(
|
59
|
+
"Skipping export of '#{serializer.folder}' " \
|
60
|
+
"as '#{local_folder.msf_path}' exists"
|
61
|
+
)
|
62
|
+
true
|
63
|
+
end
|
64
|
+
|
65
|
+
def copy_messages
|
43
66
|
File.open(local_folder.full_path, "w") do |f|
|
44
67
|
enumerator = Serializer::MboxEnumerator.new(serializer.mbox_pathname)
|
45
|
-
enumerator.each
|
68
|
+
enumerator.each do |raw|
|
46
69
|
clean = Email::Mboxrd::Message.clean_serialized(raw)
|
47
70
|
timestamp = Time.now.strftime("%a %b %d %H:%M:%S %Y")
|
48
71
|
thunderbird_fom_line = "From - #{timestamp}"
|
@@ -50,12 +73,8 @@ module Imap::Backup
|
|
50
73
|
f.write output
|
51
74
|
end
|
52
75
|
end
|
53
|
-
|
54
|
-
true
|
55
76
|
end
|
56
77
|
|
57
|
-
private
|
58
|
-
|
59
78
|
def local_folder
|
60
79
|
@local_folder ||= begin
|
61
80
|
top_level_folders = [EXPORT_PREFIX, email]
|
data/lib/imap/backup/uploader.rb
CHANGED
@@ -9,27 +9,65 @@ module Imap::Backup
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def run
|
12
|
-
|
12
|
+
if folder.uids.any?
|
13
|
+
rename_serialized_folder
|
14
|
+
else
|
15
|
+
folder.create
|
16
|
+
serializer.force_uid_validity(folder.uid_validity)
|
17
|
+
end
|
18
|
+
|
13
19
|
return if count.zero?
|
14
20
|
|
15
|
-
|
21
|
+
Logger.logger.debug "[#{folder.name}] #{count} to restore"
|
16
22
|
serializer.each_message(missing_uids).with_index do |(uid, message), i|
|
17
|
-
|
23
|
+
upload_message uid, message, i + 1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def upload_message(uid, message, index)
|
30
|
+
return if message.nil?
|
18
31
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
32
|
+
log_prefix = "[#{folder.name}] uid: #{uid} (#{index}/#{count}) -"
|
33
|
+
Logger.logger.debug(
|
34
|
+
"#{log_prefix} #{message.supplied_body.size} bytes"
|
35
|
+
)
|
23
36
|
|
37
|
+
begin
|
24
38
|
new_uid = folder.append(message)
|
25
39
|
serializer.update_uid(uid, new_uid)
|
40
|
+
rescue StandardError => e
|
41
|
+
Logger.logger.warn "#{log_prefix} append error: #{e}"
|
26
42
|
end
|
27
43
|
end
|
28
44
|
|
29
|
-
|
45
|
+
def count
|
46
|
+
@count ||= missing_uids.count
|
47
|
+
end
|
30
48
|
|
31
49
|
def missing_uids
|
32
50
|
serializer.uids - folder.uids
|
33
51
|
end
|
52
|
+
|
53
|
+
def rename_serialized_folder
|
54
|
+
Logger.logger.debug(
|
55
|
+
"There's already a '#{folder.name}' folder with emails"
|
56
|
+
)
|
57
|
+
|
58
|
+
# Rename the local folder to a unique name
|
59
|
+
new_name = serializer.apply_uid_validity(folder.uid_validity)
|
60
|
+
|
61
|
+
return if !new_name
|
62
|
+
|
63
|
+
# Restore the renamed folder
|
64
|
+
Logger.logger.debug(
|
65
|
+
"Backup '#{serializer.folder}' renamed and restored to '#{new_name}'"
|
66
|
+
)
|
67
|
+
@folder = Account::Folder.new(folder.connection, new_name)
|
68
|
+
folder.create
|
69
|
+
@serializer = Serializer.new(serializer.path, new_name)
|
70
|
+
serializer.force_uid_validity(@folder.uid_validity)
|
71
|
+
end
|
34
72
|
end
|
35
73
|
end
|
data/lib/imap/backup/utils.rb
CHANGED
data/lib/imap/backup/version.rb
CHANGED
data/lib/imap/backup.rb
CHANGED
@@ -14,7 +14,6 @@ require "imap/backup/setup/asker"
|
|
14
14
|
require "imap/backup/setup/connection_tester"
|
15
15
|
require "imap/backup/setup/folder_chooser"
|
16
16
|
require "imap/backup/version"
|
17
|
-
require "email/provider"
|
18
17
|
|
19
18
|
module Imap::Backup
|
20
19
|
class ConfigurationNotFound < StandardError; 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: 6.
|
4
|
+
version: 6.1.0
|
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-
|
11
|
+
date: 2022-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: yard
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
description: Backup GMail, or any other IMAP email service, to disk.
|
168
182
|
email:
|
169
183
|
- joe.g.yates@gmail.com
|
@@ -186,10 +200,14 @@ files:
|
|
186
200
|
- lib/email/provider/base.rb
|
187
201
|
- lib/email/provider/fastmail.rb
|
188
202
|
- lib/email/provider/gmail.rb
|
203
|
+
- lib/email/provider/purelymail.rb
|
189
204
|
- lib/email/provider/unknown.rb
|
190
205
|
- lib/imap/backup.rb
|
191
206
|
- lib/imap/backup/account.rb
|
192
207
|
- lib/imap/backup/account/connection.rb
|
208
|
+
- lib/imap/backup/account/connection/backup_folders.rb
|
209
|
+
- lib/imap/backup/account/connection/client_factory.rb
|
210
|
+
- lib/imap/backup/account/connection/folder_names.rb
|
193
211
|
- lib/imap/backup/account/folder.rb
|
194
212
|
- lib/imap/backup/cli.rb
|
195
213
|
- lib/imap/backup/cli/accounts.rb
|
@@ -201,6 +219,7 @@ files:
|
|
201
219
|
- lib/imap/backup/cli/remote.rb
|
202
220
|
- lib/imap/backup/cli/restore.rb
|
203
221
|
- lib/imap/backup/cli/setup.rb
|
222
|
+
- lib/imap/backup/cli/stats.rb
|
204
223
|
- lib/imap/backup/cli/status.rb
|
205
224
|
- lib/imap/backup/cli/utils.rb
|
206
225
|
- lib/imap/backup/client/apple_mail.rb
|
@@ -211,14 +230,20 @@ files:
|
|
211
230
|
- lib/imap/backup/migrator.rb
|
212
231
|
- lib/imap/backup/sanitizer.rb
|
213
232
|
- lib/imap/backup/serializer.rb
|
233
|
+
- lib/imap/backup/serializer/appender.rb
|
214
234
|
- lib/imap/backup/serializer/directory.rb
|
215
235
|
- lib/imap/backup/serializer/imap.rb
|
216
236
|
- lib/imap/backup/serializer/mbox.rb
|
217
237
|
- lib/imap/backup/serializer/mbox_enumerator.rb
|
238
|
+
- lib/imap/backup/serializer/message_enumerator.rb
|
239
|
+
- lib/imap/backup/serializer/unused_name_finder.rb
|
218
240
|
- lib/imap/backup/setup.rb
|
219
241
|
- lib/imap/backup/setup/account.rb
|
242
|
+
- lib/imap/backup/setup/account/header.rb
|
220
243
|
- lib/imap/backup/setup/asker.rb
|
244
|
+
- lib/imap/backup/setup/backup_path.rb
|
221
245
|
- lib/imap/backup/setup/connection_tester.rb
|
246
|
+
- lib/imap/backup/setup/email.rb
|
222
247
|
- lib/imap/backup/setup/folder_chooser.rb
|
223
248
|
- lib/imap/backup/setup/helpers.rb
|
224
249
|
- lib/imap/backup/thunderbird/mailbox_exporter.rb
|
@@ -226,74 +251,11 @@ files:
|
|
226
251
|
- lib/imap/backup/utils.rb
|
227
252
|
- lib/imap/backup/version.rb
|
228
253
|
- lib/retry_on_error.rb
|
229
|
-
- spec/features/backup_spec.rb
|
230
|
-
- spec/features/configuration/minimal_configuration.rb
|
231
|
-
- spec/features/configuration/missing_configuration.rb
|
232
|
-
- spec/features/folders_spec.rb
|
233
|
-
- spec/features/helper.rb
|
234
|
-
- spec/features/local/list_accounts_spec.rb
|
235
|
-
- spec/features/local/list_emails_spec.rb
|
236
|
-
- spec/features/local/list_folders_spec.rb
|
237
|
-
- spec/features/local/show_an_email_spec.rb
|
238
|
-
- spec/features/migrate_spec.rb
|
239
|
-
- spec/features/remote/list_account_folders_spec.rb
|
240
|
-
- spec/features/restore_spec.rb
|
241
|
-
- spec/features/status_spec.rb
|
242
|
-
- spec/features/support/aruba.rb
|
243
|
-
- spec/features/support/backup_directory.rb
|
244
|
-
- spec/features/support/email_server.rb
|
245
|
-
- spec/features/support/shared/connection_context.rb
|
246
|
-
- spec/features/support/shared/message_fixtures.rb
|
247
|
-
- spec/fixtures/connection.yml
|
248
|
-
- spec/spec_helper.rb
|
249
|
-
- spec/support/fixtures.rb
|
250
|
-
- spec/support/higline_test_helpers.rb
|
251
|
-
- spec/support/silence_logging.rb
|
252
|
-
- spec/unit/email/mboxrd/message_spec.rb
|
253
|
-
- spec/unit/email/provider/apple_mail_spec.rb
|
254
|
-
- spec/unit/email/provider/base_spec.rb
|
255
|
-
- spec/unit/email/provider/fastmail_spec.rb
|
256
|
-
- spec/unit/email/provider/gmail_spec.rb
|
257
|
-
- spec/unit/email/provider_spec.rb
|
258
|
-
- spec/unit/imap/backup/account/connection_spec.rb
|
259
|
-
- spec/unit/imap/backup/account/folder_spec.rb
|
260
|
-
- spec/unit/imap/backup/account_spec.rb
|
261
|
-
- spec/unit/imap/backup/cli/accounts_spec.rb
|
262
|
-
- spec/unit/imap/backup/cli/backup_spec.rb
|
263
|
-
- spec/unit/imap/backup/cli/folders_spec.rb
|
264
|
-
- spec/unit/imap/backup/cli/helpers_spec.rb
|
265
|
-
- spec/unit/imap/backup/cli/local_spec.rb
|
266
|
-
- spec/unit/imap/backup/cli/migrate_spec.rb
|
267
|
-
- spec/unit/imap/backup/cli/restore_spec.rb
|
268
|
-
- spec/unit/imap/backup/cli/setup_spec.rb
|
269
|
-
- spec/unit/imap/backup/cli/utils_spec.rb
|
270
|
-
- spec/unit/imap/backup/cli_spec.rb
|
271
|
-
- spec/unit/imap/backup/client/apple_mail_spec.rb
|
272
|
-
- spec/unit/imap/backup/client/default_spec.rb
|
273
|
-
- spec/unit/imap/backup/configuration_spec.rb
|
274
|
-
- spec/unit/imap/backup/downloader_spec.rb
|
275
|
-
- spec/unit/imap/backup/logger_spec.rb
|
276
|
-
- spec/unit/imap/backup/migrator_spec.rb
|
277
|
-
- spec/unit/imap/backup/sanitizer_spec.rb
|
278
|
-
- spec/unit/imap/backup/serializer/directory_spec.rb
|
279
|
-
- spec/unit/imap/backup/serializer/imap_spec.rb
|
280
|
-
- spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb
|
281
|
-
- spec/unit/imap/backup/serializer/mbox_spec.rb
|
282
|
-
- spec/unit/imap/backup/serializer_spec.rb
|
283
|
-
- spec/unit/imap/backup/setup/account_spec.rb
|
284
|
-
- spec/unit/imap/backup/setup/asker_spec.rb
|
285
|
-
- spec/unit/imap/backup/setup/connection_tester_spec.rb
|
286
|
-
- spec/unit/imap/backup/setup/folder_chooser_spec.rb
|
287
|
-
- spec/unit/imap/backup/setup/helpers_spec.rb
|
288
|
-
- spec/unit/imap/backup/setup_spec.rb
|
289
|
-
- spec/unit/imap/backup/thunderbird/mailbox_exporter_spec.rb
|
290
|
-
- spec/unit/imap/backup/uploader_spec.rb
|
291
|
-
- spec/unit/imap/backup/utils_spec.rb
|
292
|
-
- spec/unit/retry_on_error_spec.rb
|
293
254
|
homepage: https://github.com/joeyates/imap-backup
|
294
255
|
licenses:
|
295
256
|
- MIT
|
296
|
-
metadata:
|
257
|
+
metadata:
|
258
|
+
rubygems_mfa_required: 'true'
|
297
259
|
post_install_message:
|
298
260
|
rdoc_options: []
|
299
261
|
require_paths:
|
@@ -305,76 +267,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
305
267
|
version: '2.5'
|
306
268
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
307
269
|
requirements:
|
308
|
-
- - "
|
270
|
+
- - ">="
|
309
271
|
- !ruby/object:Gem::Version
|
310
|
-
version:
|
272
|
+
version: '0'
|
311
273
|
requirements: []
|
312
274
|
rubygems_version: 3.1.6
|
313
275
|
signing_key:
|
314
276
|
specification_version: 4
|
315
277
|
summary: Backup GMail (or other IMAP) accounts to disk
|
316
|
-
test_files:
|
317
|
-
- spec/spec_helper.rb
|
318
|
-
- spec/unit/imap/backup/account_spec.rb
|
319
|
-
- spec/unit/imap/backup/serializer/imap_spec.rb
|
320
|
-
- spec/unit/imap/backup/serializer/directory_spec.rb
|
321
|
-
- spec/unit/imap/backup/serializer/mbox_spec.rb
|
322
|
-
- spec/unit/imap/backup/serializer/mbox_enumerator_spec.rb
|
323
|
-
- spec/unit/imap/backup/cli_spec.rb
|
324
|
-
- spec/unit/imap/backup/setup_spec.rb
|
325
|
-
- spec/unit/imap/backup/logger_spec.rb
|
326
|
-
- spec/unit/imap/backup/configuration_spec.rb
|
327
|
-
- spec/unit/imap/backup/setup/account_spec.rb
|
328
|
-
- spec/unit/imap/backup/setup/connection_tester_spec.rb
|
329
|
-
- spec/unit/imap/backup/setup/asker_spec.rb
|
330
|
-
- spec/unit/imap/backup/setup/helpers_spec.rb
|
331
|
-
- spec/unit/imap/backup/setup/folder_chooser_spec.rb
|
332
|
-
- spec/unit/imap/backup/cli/folders_spec.rb
|
333
|
-
- spec/unit/imap/backup/cli/setup_spec.rb
|
334
|
-
- spec/unit/imap/backup/cli/backup_spec.rb
|
335
|
-
- spec/unit/imap/backup/cli/restore_spec.rb
|
336
|
-
- spec/unit/imap/backup/cli/helpers_spec.rb
|
337
|
-
- spec/unit/imap/backup/cli/accounts_spec.rb
|
338
|
-
- spec/unit/imap/backup/cli/migrate_spec.rb
|
339
|
-
- spec/unit/imap/backup/cli/utils_spec.rb
|
340
|
-
- spec/unit/imap/backup/cli/local_spec.rb
|
341
|
-
- spec/unit/imap/backup/downloader_spec.rb
|
342
|
-
- spec/unit/imap/backup/migrator_spec.rb
|
343
|
-
- spec/unit/imap/backup/uploader_spec.rb
|
344
|
-
- spec/unit/imap/backup/account/folder_spec.rb
|
345
|
-
- spec/unit/imap/backup/account/connection_spec.rb
|
346
|
-
- spec/unit/imap/backup/utils_spec.rb
|
347
|
-
- spec/unit/imap/backup/serializer_spec.rb
|
348
|
-
- spec/unit/imap/backup/client/default_spec.rb
|
349
|
-
- spec/unit/imap/backup/client/apple_mail_spec.rb
|
350
|
-
- spec/unit/imap/backup/thunderbird/mailbox_exporter_spec.rb
|
351
|
-
- spec/unit/imap/backup/sanitizer_spec.rb
|
352
|
-
- spec/unit/retry_on_error_spec.rb
|
353
|
-
- spec/unit/email/mboxrd/message_spec.rb
|
354
|
-
- spec/unit/email/provider/gmail_spec.rb
|
355
|
-
- spec/unit/email/provider/apple_mail_spec.rb
|
356
|
-
- spec/unit/email/provider/fastmail_spec.rb
|
357
|
-
- spec/unit/email/provider/base_spec.rb
|
358
|
-
- spec/unit/email/provider_spec.rb
|
359
|
-
- spec/features/folders_spec.rb
|
360
|
-
- spec/features/configuration/missing_configuration.rb
|
361
|
-
- spec/features/configuration/minimal_configuration.rb
|
362
|
-
- spec/features/backup_spec.rb
|
363
|
-
- spec/features/helper.rb
|
364
|
-
- spec/features/restore_spec.rb
|
365
|
-
- spec/features/local/list_emails_spec.rb
|
366
|
-
- spec/features/local/list_accounts_spec.rb
|
367
|
-
- spec/features/local/show_an_email_spec.rb
|
368
|
-
- spec/features/local/list_folders_spec.rb
|
369
|
-
- spec/features/status_spec.rb
|
370
|
-
- spec/features/support/email_server.rb
|
371
|
-
- spec/features/support/backup_directory.rb
|
372
|
-
- spec/features/support/aruba.rb
|
373
|
-
- spec/features/support/shared/connection_context.rb
|
374
|
-
- spec/features/support/shared/message_fixtures.rb
|
375
|
-
- spec/features/migrate_spec.rb
|
376
|
-
- spec/features/remote/list_account_folders_spec.rb
|
377
|
-
- spec/support/fixtures.rb
|
378
|
-
- spec/support/silence_logging.rb
|
379
|
-
- spec/support/higline_test_helpers.rb
|
380
|
-
- spec/fixtures/connection.yml
|
278
|
+
test_files: []
|
@@ -1,100 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "backup", type: :aruba, docker: true do
|
4
|
-
include_context "imap-backup connection"
|
5
|
-
include_context "message-fixtures"
|
6
|
-
|
7
|
-
let(:local_backup_path) { File.expand_path("~/backup") }
|
8
|
-
let(:backup_folders) { [{name: folder}] }
|
9
|
-
let(:folder) { "my-stuff" }
|
10
|
-
let(:messages_as_mbox) do
|
11
|
-
message_as_mbox_entry(msg1) + message_as_mbox_entry(msg2)
|
12
|
-
end
|
13
|
-
|
14
|
-
let!(:pre) {}
|
15
|
-
let!(:setup) do
|
16
|
-
server_create_folder folder
|
17
|
-
send_email folder, msg1
|
18
|
-
send_email folder, msg2
|
19
|
-
create_config(accounts: [account.to_h])
|
20
|
-
|
21
|
-
run_command_and_stop("imap-backup backup")
|
22
|
-
end
|
23
|
-
|
24
|
-
after do
|
25
|
-
server_delete_folder folder
|
26
|
-
end
|
27
|
-
|
28
|
-
it "downloads messages" do
|
29
|
-
expect(mbox_content(folder)).to eq(messages_as_mbox)
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "IMAP metadata" do
|
33
|
-
let(:imap_metadata) { imap_parsed(folder) }
|
34
|
-
let(:folder_uids) { server_uids(folder) }
|
35
|
-
|
36
|
-
it "saves IMAP metadata in a JSON file" do
|
37
|
-
expect { imap_metadata }.to_not raise_error
|
38
|
-
end
|
39
|
-
|
40
|
-
it "saves a file version" do
|
41
|
-
expect(imap_metadata[:version].to_s).to match(/^[0-9.]$/)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "records IMAP ids" do
|
45
|
-
expect(imap_metadata[:uids]).to eq(folder_uids)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "records uid_validity" do
|
49
|
-
expect(imap_metadata[:uid_validity]).to eq(server_uid_validity(folder))
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when uid_validity does not match" do
|
53
|
-
let(:new_name) { "NEWNAME" }
|
54
|
-
let(:original_folder_uid_validity) { server_uid_validity(folder) }
|
55
|
-
let!(:pre) do
|
56
|
-
server_create_folder folder
|
57
|
-
send_email folder, msg3
|
58
|
-
original_folder_uid_validity
|
59
|
-
connection.run_backup
|
60
|
-
connection.disconnect
|
61
|
-
server_rename_folder folder, new_name
|
62
|
-
end
|
63
|
-
let(:renamed_folder) { "#{folder}-#{original_folder_uid_validity}" }
|
64
|
-
|
65
|
-
after do
|
66
|
-
server_delete_folder new_name
|
67
|
-
end
|
68
|
-
|
69
|
-
it "renames the old backup" do
|
70
|
-
expect(mbox_content(renamed_folder)).to eq(message_as_mbox_entry(msg3))
|
71
|
-
end
|
72
|
-
|
73
|
-
it "renames the old metadata file" do
|
74
|
-
expect(imap_parsed(renamed_folder)).to be_a Hash
|
75
|
-
end
|
76
|
-
|
77
|
-
it "downloads messages" do
|
78
|
-
expect(mbox_content(folder)).to eq(messages_as_mbox)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "creates a metadata file" do
|
82
|
-
expect(imap_parsed(folder)).to be_a Hash
|
83
|
-
end
|
84
|
-
|
85
|
-
context "when a renamed local backup exists" do
|
86
|
-
let!(:pre) do
|
87
|
-
super()
|
88
|
-
create_directory local_backup_path
|
89
|
-
File.write(imap_path(renamed_folder), "existing imap")
|
90
|
-
File.write(mbox_path(renamed_folder), "existing mbox")
|
91
|
-
end
|
92
|
-
|
93
|
-
it "moves the old backup to a uniquely named directory" do
|
94
|
-
renamed = "#{folder}-#{original_folder_uid_validity}-1"
|
95
|
-
expect(mbox_content(renamed)).to eq(message_as_mbox_entry(msg3))
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "Running commands", type: :aruba do
|
4
|
-
before do
|
5
|
-
create_config(accounts: [])
|
6
|
-
run_command("imap-backup local accounts")
|
7
|
-
last_command_started.stop
|
8
|
-
end
|
9
|
-
|
10
|
-
context "when no accounts are configured" do
|
11
|
-
it "succeeds" do
|
12
|
-
expect(last_command_started).to have_exit_status(0)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
|
3
|
-
RSpec.describe "Running commands", type: :aruba do
|
4
|
-
before do
|
5
|
-
run_command("imap-backup")
|
6
|
-
last_command_started.stop
|
7
|
-
end
|
8
|
-
|
9
|
-
context "when the configuration file is missing" do
|
10
|
-
it "fails" do
|
11
|
-
expect(last_command_started).not_to have_exit_status(0)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require "features/helper"
|
2
|
-
require "imap/backup/cli/folders"
|
3
|
-
|
4
|
-
RSpec.describe "folders", type: :feature, docker: true do
|
5
|
-
include_context "imap-backup connection"
|
6
|
-
|
7
|
-
let(:options) do
|
8
|
-
{accounts: "address@example.org"}
|
9
|
-
end
|
10
|
-
let(:folder) { "my-stuff" }
|
11
|
-
let(:output) { StringIO.new }
|
12
|
-
|
13
|
-
before do
|
14
|
-
allow(Imap::Backup::CLI::Accounts).to receive(:new) { [account] }
|
15
|
-
server_create_folder folder
|
16
|
-
end
|
17
|
-
|
18
|
-
around do |example|
|
19
|
-
stdout = $stdout
|
20
|
-
$stdout = output
|
21
|
-
example.run
|
22
|
-
$stdout = stdout
|
23
|
-
end
|
24
|
-
|
25
|
-
after do
|
26
|
-
FileUtils.rm_rf local_backup_path
|
27
|
-
server_delete_folder folder
|
28
|
-
connection.disconnect
|
29
|
-
end
|
30
|
-
|
31
|
-
it "lists account folders" do
|
32
|
-
Imap::Backup::CLI::Folders.new(options).run
|
33
|
-
|
34
|
-
expect(output.string).to match(/^\tmy-stuff\n/)
|
35
|
-
end
|
36
|
-
end
|
data/spec/features/helper.rb
DELETED