imap-backup 5.2.0 → 6.0.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 +9 -2
- data/docs/development.md +10 -4
- data/imap-backup.gemspec +5 -1
- data/lib/cli_coverage.rb +11 -11
- data/lib/email/provider/base.rb +2 -0
- data/lib/email/provider/unknown.rb +2 -0
- data/lib/email/provider.rb +2 -0
- data/lib/imap/backup/account/connection/backup_folders.rb +27 -0
- data/lib/imap/backup/account/connection/client_factory.rb +54 -0
- data/lib/imap/backup/account/connection/folder_names.rb +26 -0
- data/lib/imap/backup/account/connection.rb +17 -105
- data/lib/imap/backup/account/folder.rb +9 -6
- data/lib/imap/backup/account.rb +36 -16
- data/lib/imap/backup/cli/backup.rb +1 -3
- data/lib/imap/backup/cli/folders.rb +3 -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 +5 -11
- 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 +6 -8
- data/lib/imap/backup/cli.rb +24 -3
- data/lib/imap/backup/configuration.rb +9 -21
- data/lib/imap/backup/downloader.rb +56 -34
- 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/directory.rb +37 -0
- data/lib/imap/backup/serializer/imap.rb +144 -0
- data/lib/imap/backup/serializer/mbox.rb +33 -88
- data/lib/imap/backup/serializer/mbox_enumerator.rb +2 -0
- 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 +160 -3
- data/lib/imap/backup/setup/account/header.rb +75 -0
- data/lib/imap/backup/setup/account.rb +41 -95
- data/lib/imap/backup/setup/asker.rb +4 -15
- data/lib/imap/backup/setup/backup_path.rb +41 -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 +2 -2
- data/lib/imap/backup/setup.rb +5 -4
- data/lib/imap/backup/thunderbird/mailbox_exporter.rb +41 -22
- data/lib/imap/backup/uploader.rb +46 -8
- data/lib/imap/backup/utils.rb +1 -1
- data/lib/imap/backup/version.rb +3 -3
- data/lib/imap/backup.rb +0 -2
- metadata +31 -105
- data/lib/imap/backup/serializer/mbox_store.rb +0 -217
- data/spec/features/backup_spec.rb +0 -108
- 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 -77
- 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 -405
- data/spec/unit/imap/backup/account/folder_spec.rb +0 -251
- data/spec/unit/imap/backup/cli/accounts_spec.rb +0 -47
- data/spec/unit/imap/backup/cli/helpers_spec.rb +0 -87
- data/spec/unit/imap/backup/cli/local_spec.rb +0 -81
- data/spec/unit/imap/backup/cli/utils_spec.rb +0 -62
- 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 -44
- 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/serializer/mbox_enumerator_spec.rb +0 -45
- data/spec/unit/imap/backup/serializer/mbox_spec.rb +0 -222
- data/spec/unit/imap/backup/serializer/mbox_store_spec.rb +0 -329
- data/spec/unit/imap/backup/setup/account_spec.rb +0 -366
- 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_spec.rb +0 -301
- data/spec/unit/imap/backup/uploader_spec.rb +0 -54
- data/spec/unit/imap/backup/utils_spec.rb +0 -92
|
@@ -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
|