imap-backup 9.3.2 → 10.0.0
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/lib/imap/backup/account/backup.rb +65 -0
- data/lib/imap/backup/account/{connection/backup_folders.rb → backup_folders.rb} +12 -5
- data/lib/imap/backup/account/{connection/client_factory.rb → client_factory.rb} +11 -11
- data/lib/imap/backup/account/folder.rb +8 -14
- data/lib/imap/backup/account/folder_ensurer.rb +24 -0
- data/lib/imap/backup/account/local_only_folder_deleter.rb +26 -0
- data/lib/imap/backup/account/restore.rb +20 -0
- data/lib/imap/backup/account/serialized_folders.rb +41 -0
- data/lib/imap/backup/account.rb +16 -4
- data/lib/imap/backup/cli/backup.rb +6 -7
- data/lib/imap/backup/cli/folder_enumerator.rb +1 -1
- data/lib/imap/backup/cli/helpers.rb +15 -15
- data/lib/imap/backup/cli/local.rb +31 -19
- data/lib/imap/backup/cli/mirror.rb +1 -1
- data/lib/imap/backup/cli/remote.rb +8 -8
- data/lib/imap/backup/cli/restore.rb +10 -14
- data/lib/imap/backup/cli/stats.rb +8 -3
- data/lib/imap/backup/cli/utils.rb +14 -5
- data/lib/imap/backup/cli.rb +0 -9
- data/lib/imap/backup/client/default.rb +28 -5
- data/lib/imap/backup/configuration.rb +8 -2
- data/lib/imap/backup/downloader.rb +4 -1
- data/lib/imap/backup/file_mode.rb +16 -0
- data/lib/imap/backup/mirror.rb +1 -2
- data/lib/imap/backup/serializer/directory.rb +6 -4
- data/lib/imap/backup/serializer/folder_maker.rb +33 -0
- data/lib/imap/backup/serializer/permission_checker.rb +26 -0
- data/lib/imap/backup/serializer.rb +1 -1
- data/lib/imap/backup/setup/connection_tester.rb +1 -7
- data/lib/imap/backup/setup/folder_chooser.rb +9 -9
- data/lib/imap/backup/thunderbird/mailbox_exporter.rb +34 -7
- data/lib/imap/backup/uploader.rb +1 -1
- data/lib/imap/backup/version.rb +3 -3
- data/lib/imap/backup.rb +0 -2
- metadata +12 -7
- data/lib/imap/backup/account/connection/folder_names.rb +0 -26
- data/lib/imap/backup/account/connection.rb +0 -136
- data/lib/imap/backup/utils.rb +0 -40
@@ -1,3 +1,5 @@
|
|
1
|
+
require "imap/backup/account/backup_folders"
|
2
|
+
require "imap/backup/account/serialized_folders"
|
1
3
|
require "imap/backup/thunderbird/mailbox_exporter"
|
2
4
|
|
3
5
|
module Imap::Backup
|
@@ -14,12 +16,15 @@ module Imap::Backup
|
|
14
16
|
def ignore_history(email)
|
15
17
|
Logger.setup_logging options
|
16
18
|
config = load_config(**options)
|
17
|
-
|
19
|
+
account = account(config, email)
|
18
20
|
|
19
|
-
|
21
|
+
backup_folders = Account::BackupFolders.new(
|
22
|
+
client: account.client, account: account
|
23
|
+
)
|
24
|
+
backup_folders.each do |folder|
|
20
25
|
next if !folder.exist?
|
21
26
|
|
22
|
-
serializer = Serializer.new(
|
27
|
+
serializer = Serializer.new(account.local_path, folder.name)
|
23
28
|
do_ignore_folder_history(folder, serializer)
|
24
29
|
end
|
25
30
|
end
|
@@ -52,7 +57,7 @@ module Imap::Backup
|
|
52
57
|
profile_name = options[:profile]
|
53
58
|
|
54
59
|
config = load_config(**options)
|
55
|
-
|
60
|
+
account = account(config, email)
|
56
61
|
profile = thunderbird_profile(profile_name)
|
57
62
|
|
58
63
|
if !profile
|
@@ -61,7 +66,11 @@ module Imap::Backup
|
|
61
66
|
raise "Default Thunderbird profile not found"
|
62
67
|
end
|
63
68
|
|
64
|
-
|
69
|
+
serialized_folders = Account::SerializedFolders.new(account: account)
|
70
|
+
|
71
|
+
raise "No serialized folders were found for account '#{email}'" if serialized_folders.none?
|
72
|
+
|
73
|
+
serialized_folders.each do |serializer, _folder|
|
65
74
|
Thunderbird::MailboxExporter.new(
|
66
75
|
email, serializer, profile, force: force
|
67
76
|
).run
|
data/lib/imap/backup/cli.rb
CHANGED
@@ -49,15 +49,6 @@ module Imap::Backup
|
|
49
49
|
true
|
50
50
|
end
|
51
51
|
|
52
|
-
def self.accounts_option
|
53
|
-
method_option(
|
54
|
-
"accounts",
|
55
|
-
type: :string,
|
56
|
-
desc: "a comma-separated list of accounts (defaults to all configured accounts)",
|
57
|
-
aliases: ["-a"]
|
58
|
-
)
|
59
|
-
end
|
60
|
-
|
61
52
|
desc "backup [OPTIONS]", "Run the backup"
|
62
53
|
long_desc <<~DESC
|
63
54
|
Downloads any emails not yet present locally.
|
@@ -7,15 +7,19 @@ module Imap::Backup
|
|
7
7
|
class Client::Default
|
8
8
|
extend Forwardable
|
9
9
|
def_delegators :imap, *%i(
|
10
|
-
append authenticate create expunge
|
10
|
+
append authenticate create expunge namespace
|
11
11
|
responses uid_fetch uid_search uid_store
|
12
12
|
)
|
13
13
|
|
14
|
-
attr_reader :
|
14
|
+
attr_reader :account
|
15
|
+
attr_reader :options
|
16
|
+
attr_reader :server
|
15
17
|
attr_accessor :state
|
16
18
|
|
17
|
-
def initialize(
|
18
|
-
@
|
19
|
+
def initialize(server, account, options)
|
20
|
+
@account = account
|
21
|
+
@options = options
|
22
|
+
@server = server
|
19
23
|
@state = nil
|
20
24
|
end
|
21
25
|
|
@@ -28,6 +32,21 @@ module Imap::Backup
|
|
28
32
|
mailbox_lists.map { |ml| extract_name(ml) }
|
29
33
|
end
|
30
34
|
|
35
|
+
def login
|
36
|
+
Logger.logger.debug "Logging in: #{account.username}/#{masked_password}"
|
37
|
+
imap.login(account.username, account.password)
|
38
|
+
Logger.logger.debug "Login complete"
|
39
|
+
end
|
40
|
+
|
41
|
+
def reconnect
|
42
|
+
disconnect
|
43
|
+
login
|
44
|
+
end
|
45
|
+
|
46
|
+
def username
|
47
|
+
account.username
|
48
|
+
end
|
49
|
+
|
31
50
|
# Track mailbox selection during delegation to Net::IMAP instance
|
32
51
|
|
33
52
|
def disconnect
|
@@ -53,7 +72,7 @@ module Imap::Backup
|
|
53
72
|
private
|
54
73
|
|
55
74
|
def imap
|
56
|
-
@imap ||= Net::IMAP.new(
|
75
|
+
@imap ||= Net::IMAP.new(server, options)
|
57
76
|
end
|
58
77
|
|
59
78
|
def extract_name(mailbox_list)
|
@@ -61,6 +80,10 @@ module Imap::Backup
|
|
61
80
|
Net::IMAP.decode_utf7(utf7_encoded)
|
62
81
|
end
|
63
82
|
|
83
|
+
def masked_password
|
84
|
+
account.password.gsub(/./, "x")
|
85
|
+
end
|
86
|
+
|
64
87
|
# 6.3.8. LIST Command
|
65
88
|
# An empty ("" string) mailbox name argument is a special request to
|
66
89
|
# return the hierarchy delimiter and the root name of the name given
|
@@ -1,7 +1,10 @@
|
|
1
|
+
require "fileutils"
|
1
2
|
require "json"
|
2
3
|
require "os"
|
3
4
|
|
4
5
|
require "imap/backup/account"
|
6
|
+
require "imap/backup/file_mode"
|
7
|
+
require "imap/backup/serializer/permission_checker"
|
5
8
|
|
6
9
|
module Imap::Backup
|
7
10
|
class Configuration
|
@@ -66,7 +69,10 @@ module Imap::Backup
|
|
66
69
|
def data
|
67
70
|
@data ||=
|
68
71
|
if File.exist?(pathname)
|
69
|
-
|
72
|
+
permission_checker = Serializer::PermissionChecker.new(
|
73
|
+
filename: pathname, limit: 0o600
|
74
|
+
)
|
75
|
+
permission_checker.run if !windows?
|
70
76
|
contents = File.read(pathname)
|
71
77
|
JSON.parse(contents, symbolize_names: true)
|
72
78
|
else
|
@@ -83,7 +89,7 @@ module Imap::Backup
|
|
83
89
|
end
|
84
90
|
|
85
91
|
def make_private(path)
|
86
|
-
FileUtils.chmod(0o700, path) if
|
92
|
+
FileUtils.chmod(0o700, path) if FileMode.new(filename: path).mode != 0o700
|
87
93
|
end
|
88
94
|
|
89
95
|
def windows?
|
@@ -24,7 +24,7 @@ module Imap::Backup
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def run
|
27
|
-
|
27
|
+
info("#{uids.count} new messages") if uids.any?
|
28
28
|
|
29
29
|
uids.each_slice(multi_fetch_size).with_index do |block, i|
|
30
30
|
multifetch_failed = download_block(block, i)
|
@@ -35,6 +35,9 @@ module Imap::Backup
|
|
35
35
|
@multi_fetch_size = 1
|
36
36
|
@uids = nil
|
37
37
|
retry
|
38
|
+
rescue Net::IMAP::ByeResponseError
|
39
|
+
folder.client.reconnect
|
40
|
+
retry
|
38
41
|
end
|
39
42
|
|
40
43
|
private
|
data/lib/imap/backup/mirror.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "os"
|
2
2
|
|
3
|
+
require "imap/backup/serializer/folder_maker"
|
4
|
+
|
3
5
|
module Imap::Backup
|
4
6
|
class Serializer; end
|
5
7
|
|
@@ -16,13 +18,13 @@ module Imap::Backup
|
|
16
18
|
|
17
19
|
def ensure_exists
|
18
20
|
if !File.directory?(full_path)
|
19
|
-
|
20
|
-
path, relative, DIRECTORY_PERMISSIONS
|
21
|
-
)
|
21
|
+
Serializer::FolderMaker.new(
|
22
|
+
base: path, path: relative, permissions: DIRECTORY_PERMISSIONS
|
23
|
+
).run
|
22
24
|
end
|
23
25
|
|
24
26
|
return if OS.windows?
|
25
|
-
return if
|
27
|
+
return if FileMode.new(filename: full_path).mode == DIRECTORY_PERMISSIONS
|
26
28
|
|
27
29
|
FileUtils.chmod DIRECTORY_PERMISSIONS, full_path
|
28
30
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
module Imap::Backup
|
4
|
+
class Serializer; end
|
5
|
+
|
6
|
+
class Serializer::FolderMaker
|
7
|
+
attr_reader :base
|
8
|
+
attr_reader :path
|
9
|
+
attr_reader :permissions
|
10
|
+
|
11
|
+
def initialize(base:, path:, permissions:)
|
12
|
+
@base = base
|
13
|
+
@path = path
|
14
|
+
@permissions = permissions
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
parts = path.split("/")
|
19
|
+
return if parts.empty?
|
20
|
+
|
21
|
+
FileUtils.mkdir_p(full_path) if !File.exist?(full_path)
|
22
|
+
full = base
|
23
|
+
parts.each do |part|
|
24
|
+
full = File.join(full, part)
|
25
|
+
FileUtils.chmod permissions, full
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def full_path
|
30
|
+
File.join(base, path)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Imap::Backup
|
2
|
+
class Serializer::PermissionChecker
|
3
|
+
attr_reader :filename
|
4
|
+
attr_reader :limit
|
5
|
+
|
6
|
+
def initialize(filename:, limit:)
|
7
|
+
@filename = filename
|
8
|
+
@limit = limit
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
actual = FileMode.new(filename: filename).mode
|
13
|
+
return nil if actual.nil?
|
14
|
+
|
15
|
+
mask = ~limit & 0o777
|
16
|
+
return if (actual & mask).zero?
|
17
|
+
|
18
|
+
message = format(
|
19
|
+
"Permissions on '%<filename>s' " \
|
20
|
+
"should be 0%<limit>o, not 0%<actual>o",
|
21
|
+
filename: filename, limit: limit, actual: actual
|
22
|
+
)
|
23
|
+
raise message
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -9,18 +9,12 @@ module Imap::Backup
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def test
|
12
|
-
|
12
|
+
account.client
|
13
13
|
"Connection successful"
|
14
14
|
rescue Net::IMAP::NoResponseError
|
15
15
|
"No response"
|
16
16
|
rescue StandardError => e
|
17
17
|
"Unexpected error: #{e}"
|
18
18
|
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def connection
|
23
|
-
Account::Connection.new(account)
|
24
|
-
end
|
25
19
|
end
|
26
20
|
end
|
@@ -11,13 +11,12 @@ module Imap::Backup
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def run
|
14
|
-
if
|
15
|
-
Logger.logger.warn "Connection failed"
|
14
|
+
if client.nil?
|
16
15
|
highline.ask "Press a key "
|
17
16
|
return
|
18
17
|
end
|
19
18
|
|
20
|
-
if
|
19
|
+
if folder_names.empty?
|
21
20
|
Logger.logger.warn "Unable to get folder list"
|
22
21
|
highline.ask "Press a key "
|
23
22
|
return
|
@@ -50,7 +49,7 @@ module Imap::Backup
|
|
50
49
|
end
|
51
50
|
|
52
51
|
def add_folders(menu)
|
53
|
-
|
52
|
+
folder_names.each do |folder|
|
54
53
|
mark = selected?(folder) ? "+" : "-"
|
55
54
|
menu.choice("#{mark} #{folder}") do
|
56
55
|
toggle_selection folder
|
@@ -69,7 +68,7 @@ module Imap::Backup
|
|
69
68
|
removed = []
|
70
69
|
config_folders = []
|
71
70
|
account.folders.each do |f|
|
72
|
-
found =
|
71
|
+
found = folder_names.find { |folder| folder == f[:name] }
|
73
72
|
if found
|
74
73
|
config_folders << f
|
75
74
|
else
|
@@ -98,14 +97,15 @@ module Imap::Backup
|
|
98
97
|
end
|
99
98
|
end
|
100
99
|
|
101
|
-
def
|
102
|
-
@
|
100
|
+
def client
|
101
|
+
@client ||= account.client
|
103
102
|
rescue StandardError
|
103
|
+
Logger.logger.warn "Connection failed"
|
104
104
|
nil
|
105
105
|
end
|
106
106
|
|
107
|
-
def
|
108
|
-
@
|
107
|
+
def folder_names
|
108
|
+
@folder_names ||= client.list
|
109
109
|
end
|
110
110
|
|
111
111
|
def highline
|
@@ -18,8 +18,18 @@ module Imap::Backup
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def run
|
21
|
+
if !profile_set_up
|
22
|
+
error "The Thunderbird profile '#{profile.title}' " \
|
23
|
+
"has not been set up. " \
|
24
|
+
"Please set it up before trying to export"
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
|
21
28
|
local_folder_ok = local_folder.set_up
|
22
|
-
|
29
|
+
if !local_folder_ok
|
30
|
+
error "Failed to set up local folder"
|
31
|
+
return false
|
32
|
+
end
|
23
33
|
|
24
34
|
skip_for_msf = check_msf
|
25
35
|
return false if skip_for_msf
|
@@ -27,6 +37,7 @@ module Imap::Backup
|
|
27
37
|
skip_for_local_folder = check_local_folder
|
28
38
|
return false if skip_for_local_folder
|
29
39
|
|
40
|
+
info "Exporting account '#{email}' to folder '#{local_folder.full_path}'"
|
30
41
|
copy_messages
|
31
42
|
|
32
43
|
true
|
@@ -34,15 +45,19 @@ module Imap::Backup
|
|
34
45
|
|
35
46
|
private
|
36
47
|
|
48
|
+
def profile_set_up
|
49
|
+
File.exist?(profile.local_folders_path)
|
50
|
+
end
|
51
|
+
|
37
52
|
def check_local_folder
|
38
53
|
return false if !local_folder.exists?
|
39
54
|
|
40
55
|
if force
|
41
|
-
|
56
|
+
info "Overwriting '#{local_folder.path}' as --force option was supplied"
|
42
57
|
return false
|
43
58
|
end
|
44
59
|
|
45
|
-
|
60
|
+
warning "Skipping export of '#{serializer.folder}' as '#{local_folder.full_path}' exists"
|
46
61
|
true
|
47
62
|
end
|
48
63
|
|
@@ -50,12 +65,12 @@ module Imap::Backup
|
|
50
65
|
return false if !local_folder.msf_exists?
|
51
66
|
|
52
67
|
if force
|
53
|
-
|
68
|
+
info "Deleting '#{local_folder.msf_path}' as --force option was supplied"
|
54
69
|
File.unlink local_folder.msf_path
|
55
70
|
return false
|
56
71
|
end
|
57
72
|
|
58
|
-
|
73
|
+
warning(
|
59
74
|
"Skipping export of '#{serializer.folder}' " \
|
60
75
|
"as '#{local_folder.msf_path}' exists"
|
61
76
|
)
|
@@ -66,8 +81,8 @@ module Imap::Backup
|
|
66
81
|
File.open(local_folder.full_path, "w") do |f|
|
67
82
|
serializer.messages.each do |message|
|
68
83
|
timestamp = Time.now.strftime("%a %b %d %H:%M:%S %Y")
|
69
|
-
|
70
|
-
output = "#{
|
84
|
+
thunderbird_from_line = "From - #{timestamp}"
|
85
|
+
output = "#{thunderbird_from_line}\n#{message.body}\n"
|
71
86
|
f.write output
|
72
87
|
end
|
73
88
|
end
|
@@ -80,5 +95,17 @@ module Imap::Backup
|
|
80
95
|
Thunderbird::LocalFolder.new(profile, prefixed_folder_path)
|
81
96
|
end
|
82
97
|
end
|
98
|
+
|
99
|
+
def error(message)
|
100
|
+
Logger.logger.error("[Thunderbird::MailboxExporter] #{message}")
|
101
|
+
end
|
102
|
+
|
103
|
+
def info(message)
|
104
|
+
Logger.logger.info("[Thunderbird::MailboxExporter] #{message}")
|
105
|
+
end
|
106
|
+
|
107
|
+
def warning(message)
|
108
|
+
Logger.logger.warn("[Thunderbird::MailboxExporter] #{message}")
|
109
|
+
end
|
83
110
|
end
|
84
111
|
end
|
data/lib/imap/backup/uploader.rb
CHANGED
@@ -64,7 +64,7 @@ module Imap::Backup
|
|
64
64
|
Logger.logger.debug(
|
65
65
|
"Backup '#{serializer.folder}' renamed and restored to '#{new_name}'"
|
66
66
|
)
|
67
|
-
@folder = Account::Folder.new(folder.
|
67
|
+
@folder = Account::Folder.new(folder.client, new_name)
|
68
68
|
folder.create
|
69
69
|
@serializer = Serializer.new(serializer.path, new_name)
|
70
70
|
serializer.force_uid_validity(@folder.uid_validity)
|
data/lib/imap/backup/version.rb
CHANGED
data/lib/imap/backup.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:
|
4
|
+
version: 10.0.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: 2023-07-
|
11
|
+
date: 2023-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -232,11 +232,14 @@ files:
|
|
232
232
|
- lib/email/provider/unknown.rb
|
233
233
|
- lib/imap/backup.rb
|
234
234
|
- lib/imap/backup/account.rb
|
235
|
-
- lib/imap/backup/account/
|
236
|
-
- lib/imap/backup/account/
|
237
|
-
- lib/imap/backup/account/
|
238
|
-
- lib/imap/backup/account/connection/folder_names.rb
|
235
|
+
- lib/imap/backup/account/backup.rb
|
236
|
+
- lib/imap/backup/account/backup_folders.rb
|
237
|
+
- lib/imap/backup/account/client_factory.rb
|
239
238
|
- lib/imap/backup/account/folder.rb
|
239
|
+
- lib/imap/backup/account/folder_ensurer.rb
|
240
|
+
- lib/imap/backup/account/local_only_folder_deleter.rb
|
241
|
+
- lib/imap/backup/account/restore.rb
|
242
|
+
- lib/imap/backup/account/serialized_folders.rb
|
240
243
|
- lib/imap/backup/cli.rb
|
241
244
|
- lib/imap/backup/cli/backup.rb
|
242
245
|
- lib/imap/backup/cli/folder_enumerator.rb
|
@@ -253,6 +256,7 @@ files:
|
|
253
256
|
- lib/imap/backup/client/default.rb
|
254
257
|
- lib/imap/backup/configuration.rb
|
255
258
|
- lib/imap/backup/downloader.rb
|
259
|
+
- lib/imap/backup/file_mode.rb
|
256
260
|
- lib/imap/backup/flag_refresher.rb
|
257
261
|
- lib/imap/backup/local_only_message_deleter.rb
|
258
262
|
- lib/imap/backup/logger.rb
|
@@ -263,10 +267,12 @@ files:
|
|
263
267
|
- lib/imap/backup/serializer.rb
|
264
268
|
- lib/imap/backup/serializer/appender.rb
|
265
269
|
- lib/imap/backup/serializer/directory.rb
|
270
|
+
- lib/imap/backup/serializer/folder_maker.rb
|
266
271
|
- lib/imap/backup/serializer/imap.rb
|
267
272
|
- lib/imap/backup/serializer/mbox.rb
|
268
273
|
- lib/imap/backup/serializer/message.rb
|
269
274
|
- lib/imap/backup/serializer/message_enumerator.rb
|
275
|
+
- lib/imap/backup/serializer/permission_checker.rb
|
270
276
|
- lib/imap/backup/serializer/unused_name_finder.rb
|
271
277
|
- lib/imap/backup/serializer/version2_migrator.rb
|
272
278
|
- lib/imap/backup/setup.rb
|
@@ -280,7 +286,6 @@ files:
|
|
280
286
|
- lib/imap/backup/setup/helpers.rb
|
281
287
|
- lib/imap/backup/thunderbird/mailbox_exporter.rb
|
282
288
|
- lib/imap/backup/uploader.rb
|
283
|
-
- lib/imap/backup/utils.rb
|
284
289
|
- lib/imap/backup/version.rb
|
285
290
|
- lib/retry_on_error.rb
|
286
291
|
- lib/text/sanitizer.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Imap::Backup
|
2
|
-
class Account; end
|
3
|
-
class Account::Connection; end
|
4
|
-
|
5
|
-
class Account::Connection::FolderNames
|
6
|
-
attr_reader :account
|
7
|
-
attr_reader :client
|
8
|
-
|
9
|
-
def initialize(client:, account:)
|
10
|
-
@client = client
|
11
|
-
@account = account
|
12
|
-
end
|
13
|
-
|
14
|
-
def run
|
15
|
-
folder_names = client.list
|
16
|
-
|
17
|
-
if folder_names.empty?
|
18
|
-
message = "Unable to get folder list for account #{account.username}"
|
19
|
-
Logger.logger.info message
|
20
|
-
raise message
|
21
|
-
end
|
22
|
-
|
23
|
-
folder_names
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|