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
@@ -1,92 +0,0 @@
|
|
1
|
-
describe Imap::Backup::Utils do
|
2
|
-
let(:filename) { "foobar" }
|
3
|
-
let(:stat) { instance_double(File::Stat, mode: mode) }
|
4
|
-
let(:mode) { 0o777 }
|
5
|
-
let(:exists) { true }
|
6
|
-
|
7
|
-
before do
|
8
|
-
allow(File).to receive(:stat) { stat }
|
9
|
-
allow(File).to receive(:exist?).with(filename) { exists }
|
10
|
-
end
|
11
|
-
|
12
|
-
describe ".check_permissions" do
|
13
|
-
let(:requested) { 0o345 }
|
14
|
-
|
15
|
-
context "with existing files" do
|
16
|
-
[
|
17
|
-
[0o100, "less than the limit", true],
|
18
|
-
[0o345, "equal to the limit", true],
|
19
|
-
[0o777, "over the limit", false]
|
20
|
-
].each do |mode, description, success|
|
21
|
-
context "when permissions are #{description}" do
|
22
|
-
let(:mode) { mode }
|
23
|
-
|
24
|
-
if success
|
25
|
-
it "succeeds" do
|
26
|
-
described_class.check_permissions(filename, requested)
|
27
|
-
end
|
28
|
-
else
|
29
|
-
it "fails" do
|
30
|
-
message = /Permissions on '.*?' should be .*?, not .*?/
|
31
|
-
expect do
|
32
|
-
described_class.check_permissions(filename, requested)
|
33
|
-
end.to raise_error(RuntimeError, message)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with non-existent files" do
|
41
|
-
let(:exists) { false }
|
42
|
-
let(:mode) { 0o111 }
|
43
|
-
|
44
|
-
it "succeeds" do
|
45
|
-
described_class.check_permissions(filename, requested)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe ".mode" do
|
51
|
-
context "with existing files" do
|
52
|
-
let(:mode) { 0o2345 }
|
53
|
-
|
54
|
-
it "is the last 9 bits of the file mode" do
|
55
|
-
expect(described_class.mode(filename)).to eq(0o345)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "with non-existent files" do
|
60
|
-
let(:exists) { false }
|
61
|
-
|
62
|
-
it "is nil" do
|
63
|
-
expect(described_class.mode(filename)).to be_nil
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe ".make_folder" do
|
69
|
-
before do
|
70
|
-
allow(FileUtils).to receive(:mkdir_p)
|
71
|
-
allow(FileUtils).to receive(:chmod)
|
72
|
-
end
|
73
|
-
|
74
|
-
it "does nothing if an empty path is supplied" do
|
75
|
-
expect(FileUtils).to_not receive(:mkdir_p)
|
76
|
-
|
77
|
-
described_class.make_folder("aaa", "", 0o222)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "creates the path" do
|
81
|
-
expect(FileUtils).to receive(:mkdir_p).with("/base/path/new/folder")
|
82
|
-
|
83
|
-
described_class.make_folder("/base/path", "new/folder", 0o222)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "sets permissions on the path" do
|
87
|
-
expect(FileUtils).to receive(:chmod).with(0o222, "/base/path/new/folder")
|
88
|
-
|
89
|
-
described_class.make_folder("/base/path/new", "folder", 0o222)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
class Retrier
|
2
|
-
class FooError < StandardError; end
|
3
|
-
|
4
|
-
include RetryOnError
|
5
|
-
|
6
|
-
def do_stuff(errors:, limit:)
|
7
|
-
calls = 0
|
8
|
-
|
9
|
-
retry_on_error(errors: errors, limit: limit) do
|
10
|
-
calls += 1
|
11
|
-
raise FooError if calls < 3
|
12
|
-
|
13
|
-
42
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
RSpec.describe RetryOnError do
|
19
|
-
describe "#retry_on_error" do
|
20
|
-
subject { Retrier.new }
|
21
|
-
|
22
|
-
it "retries" do
|
23
|
-
expect(subject.do_stuff(errors: [Retrier::FooError], limit: 3)).to eq(42)
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when the block fails more than the limit" do
|
27
|
-
it "fails" do
|
28
|
-
expect do
|
29
|
-
subject.do_stuff(errors: [Retrier::FooError], limit: 1)
|
30
|
-
end.to raise_error(Retrier::FooError)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|