imap-backup 5.1.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -6
- data/bin/imap-backup +4 -0
- data/imap-backup.gemspec +1 -7
- data/lib/cli_coverage.rb +18 -0
- data/lib/imap/backup/account/folder.rb +0 -16
- data/lib/imap/backup/cli.rb +1 -1
- data/lib/imap/backup/serializer/mbox.rb +2 -2
- data/lib/imap/backup/version.rb +1 -1
- data/spec/features/backup_spec.rb +2 -2
- data/spec/features/restore_spec.rb +1 -1
- data/spec/features/support/aruba.rb +4 -0
- data/spec/spec_helper.rb +2 -6
- data/spec/unit/imap/backup/account/folder_spec.rb +8 -16
- data/spec/unit/imap/backup/downloader_spec.rb +2 -2
- data/spec/unit/imap/backup/logger_spec.rb +1 -1
- data/spec/unit/imap/backup/serializer/mbox_spec.rb +4 -4
- metadata +3 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 164962561883b82372b32826843681c6a802e88982f4906778758a073e1479d8
|
4
|
+
data.tar.gz: 8a71ad18952f675f61bc6342a3a9a60c2fc71797444142c2af5f98ef18ac13e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 600ff4b72954cecfb2037b9ef12b16029248a6c6e27b2b801661b5c746264a8aed7a99aa689cbeecc8e89f571b9f4c26350669e582bc087a518981bceb677141
|
7
|
+
data.tar.gz: b706026f0b8231f10dfbb0a0c39162ccdf6a8671c513b6cbf637352dcd8d99987a3f93d2b523db7f4a8e3ff7178877dc3d84c1ad506245a9773330abea2a792f
|
data/README.md
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
[![Build Status](https://circleci.com/gh/joeyates/imap-backup.svg?style=svg)][Continuous Integration]
|
2
|
-
[![Source Analysis](https://codeclimate.com/github/joeyates/imap-backup/badges/gpa.svg)](https://codeclimate.com/github/joeyates/imap-backup)
|
3
|
-
[![Test Coverage](https://codeclimate.com/github/joeyates/imap-backup/badges/coverage.svg)](https://codeclimate.com/github/joeyates/imap-backup/coverage)
|
4
|
-
|
5
1
|
# imap-backup
|
6
2
|
|
7
3
|
*Backup GMail (or other IMAP) accounts to disk*
|
@@ -9,12 +5,10 @@
|
|
9
5
|
* [Source Code]
|
10
6
|
* [API documentation]
|
11
7
|
* [Rubygem]
|
12
|
-
* [Continuous Integration]
|
13
8
|
|
14
9
|
[Source Code]: https://github.com/joeyates/imap-backup "Source code at GitHub"
|
15
10
|
[API documentation]: http://rubydoc.info/gems/imap-backup/frames "RDoc API Documentation at Rubydoc.info"
|
16
11
|
[Rubygem]: http://rubygems.org/gems/imap-backup "Ruby gem at rubygems.org"
|
17
|
-
[Continuous Integration]: https://circleci.com/gh/joeyates/imap-backup "Build status by CirceCI"
|
18
12
|
|
19
13
|
# Installation
|
20
14
|
|
data/bin/imap-backup
CHANGED
data/imap-backup.gemspec
CHANGED
@@ -30,14 +30,8 @@ Gem::Specification.new do |gem|
|
|
30
30
|
gem.add_runtime_dependency "thunderbird", ">= 0.0.0"
|
31
31
|
|
32
32
|
gem.add_development_dependency "aruba", ">= 0.0.0"
|
33
|
-
gem.add_development_dependency "
|
34
|
-
if RUBY_ENGINE == "jruby"
|
35
|
-
gem.add_development_dependency "pry-debugger-jruby"
|
36
|
-
else
|
37
|
-
gem.add_development_dependency "pry-byebug"
|
38
|
-
end
|
33
|
+
gem.add_development_dependency "pry-byebug"
|
39
34
|
gem.add_development_dependency "rspec", ">= 3.0.0"
|
40
|
-
gem.add_development_dependency "rspec_junit_formatter"
|
41
35
|
gem.add_development_dependency "rubocop-rspec"
|
42
36
|
gem.add_development_dependency "simplecov"
|
43
37
|
end
|
data/lib/cli_coverage.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class CliCoverage
|
2
|
+
def self.conditionally_activate
|
3
|
+
if ENV["COVERAGE"]
|
4
|
+
require "simplecov"
|
5
|
+
|
6
|
+
# Collect coverage separately
|
7
|
+
SimpleCov.command_name "#{ENV['COVERAGE']} coverage"
|
8
|
+
|
9
|
+
# Silence output
|
10
|
+
SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter
|
11
|
+
SimpleCov.print_error_status = false
|
12
|
+
|
13
|
+
# Ensure SimpleCov doesn't filter out all out code
|
14
|
+
project_root = File.expand_path("..", __dir__)
|
15
|
+
SimpleCov.root project_root
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -68,22 +68,6 @@ module Imap::Backup
|
|
68
68
|
[]
|
69
69
|
end
|
70
70
|
|
71
|
-
def fetch(uid)
|
72
|
-
examine
|
73
|
-
fetch_data_items =
|
74
|
-
retry_on_error(errors: UID_FETCH_RETRY_CLASSES) do
|
75
|
-
client.uid_fetch([uid.to_i], [BODY_ATTRIBUTE])
|
76
|
-
end
|
77
|
-
return nil if fetch_data_items.nil?
|
78
|
-
|
79
|
-
fetch_data_item = fetch_data_items[0]
|
80
|
-
attributes = fetch_data_item.attr
|
81
|
-
|
82
|
-
attributes[BODY_ATTRIBUTE]
|
83
|
-
rescue FolderNotFound
|
84
|
-
nil
|
85
|
-
end
|
86
|
-
|
87
71
|
def fetch_multi(uids)
|
88
72
|
examine
|
89
73
|
fetch_data_items =
|
data/lib/imap/backup/cli.rb
CHANGED
@@ -100,7 +100,7 @@ module Imap::Backup
|
|
100
100
|
aliases: ["-s"]
|
101
101
|
)
|
102
102
|
def migrate(source_email, destination_email)
|
103
|
-
Migrate.new(source_email, destination_email, symbolized(options)).run
|
103
|
+
Migrate.new(source_email, destination_email, **symbolized(options)).run
|
104
104
|
end
|
105
105
|
|
106
106
|
desc "remote SUBCOMMAND [OPTIONS]", "View info about online accounts"
|
@@ -71,8 +71,8 @@ module Imap::Backup
|
|
71
71
|
digit = 0
|
72
72
|
new_name = nil
|
73
73
|
loop do
|
74
|
-
extra = digit.zero? ? "" : "
|
75
|
-
new_name = "#{folder}
|
74
|
+
extra = digit.zero? ? "" : "-#{digit}"
|
75
|
+
new_name = "#{folder}-#{store.uid_validity}#{extra}"
|
76
76
|
test_store = Serializer::MboxStore.new(path, new_name)
|
77
77
|
break if !test_store.exist?
|
78
78
|
|
data/lib/imap/backup/version.rb
CHANGED
@@ -60,7 +60,7 @@ RSpec.describe "backup", type: :aruba, docker: true do
|
|
60
60
|
connection.disconnect
|
61
61
|
server_rename_folder folder, new_name
|
62
62
|
end
|
63
|
-
let(:renamed_folder) { "#{folder}
|
63
|
+
let(:renamed_folder) { "#{folder}-#{original_folder_uid_validity}" }
|
64
64
|
|
65
65
|
after do
|
66
66
|
server_delete_folder new_name
|
@@ -83,7 +83,7 @@ RSpec.describe "backup", type: :aruba, docker: true do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it "moves the old backup to a uniquely named directory" do
|
86
|
-
renamed = "#{folder}
|
86
|
+
renamed = "#{folder}-#{original_folder_uid_validity}-1"
|
87
87
|
expect(mbox_content(renamed)).to eq(message_as_mbox_entry(msg3))
|
88
88
|
end
|
89
89
|
end
|
@@ -94,7 +94,7 @@ RSpec.describe "restore", type: :aruba, docker: true do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
context "when the folder has content" do
|
97
|
-
let(:new_folder) { "#{folder}
|
97
|
+
let(:new_folder) { "#{folder}-#{uid_validity}" }
|
98
98
|
let(:cleanup) do
|
99
99
|
server_delete_folder new_folder
|
100
100
|
super()
|
data/spec/spec_helper.rb
CHANGED
@@ -1,17 +1,13 @@
|
|
1
|
-
require "codeclimate-test-reporter"
|
2
1
|
require "rspec"
|
3
2
|
|
4
|
-
CodeClimate::TestReporter.start
|
5
|
-
|
6
3
|
$LOAD_PATH << File.expand_path("../lib", __dir__)
|
7
4
|
|
8
5
|
support_glob = File.join(__dir__, "support", "**", "*.rb")
|
9
6
|
Dir[support_glob].sort.each { |f| require f }
|
10
7
|
|
11
8
|
require "simplecov"
|
12
|
-
|
13
|
-
|
14
|
-
end
|
9
|
+
|
10
|
+
SimpleCov.command_name "RSpec tests"
|
15
11
|
|
16
12
|
require "imap/backup"
|
17
13
|
require "imap/backup/cli"
|
@@ -66,24 +66,24 @@ describe Imap::Backup::Account::Folder do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
describe "#
|
69
|
+
describe "#fetch_multi" do
|
70
70
|
let(:message_body) { instance_double(String, force_encoding: nil) }
|
71
|
-
let(:attributes) { {"BODY[]" => message_body, "other" => "xxx"} }
|
71
|
+
let(:attributes) { {"UID" => "uid", "BODY[]" => message_body, "other" => "xxx"} }
|
72
72
|
let(:fetch_data_item) do
|
73
73
|
instance_double(Net::IMAP::FetchData, attr: attributes)
|
74
74
|
end
|
75
75
|
|
76
76
|
before { allow(client).to receive(:uid_fetch) { [fetch_data_item] } }
|
77
77
|
|
78
|
-
it "returns the message" do
|
79
|
-
expect(subject.
|
78
|
+
it "returns the uid and message" do
|
79
|
+
expect(subject.fetch_multi([123])).to eq([{uid: "uid", body: message_body}])
|
80
80
|
end
|
81
81
|
|
82
82
|
context "when the server responds with nothing" do
|
83
83
|
before { allow(client).to receive(:uid_fetch) { nil } }
|
84
84
|
|
85
85
|
it "is nil" do
|
86
|
-
expect(subject.
|
86
|
+
expect(subject.fetch_multi([123])).to be_nil
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -94,15 +94,7 @@ describe Imap::Backup::Account::Folder do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it "is nil" do
|
97
|
-
expect(subject.
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context "when the response doesn't include 'BODY[]'" do
|
102
|
-
let(:attributes) { {} }
|
103
|
-
|
104
|
-
it "is nil" do
|
105
|
-
expect(subject.fetch(123)).to be_nil
|
97
|
+
expect(subject.fetch_multi([123])).to be_nil
|
106
98
|
end
|
107
99
|
end
|
108
100
|
|
@@ -113,13 +105,13 @@ describe Imap::Backup::Account::Folder do
|
|
113
105
|
end
|
114
106
|
|
115
107
|
it "retries" do
|
116
|
-
subject.
|
108
|
+
subject.fetch_multi([123])
|
117
109
|
|
118
110
|
expect(client).to have_received(:uid_fetch).twice
|
119
111
|
end
|
120
112
|
|
121
113
|
it "succeeds" do
|
122
|
-
subject.
|
114
|
+
subject.fetch_multi([123])
|
123
115
|
end
|
124
116
|
end
|
125
117
|
end
|
@@ -34,8 +34,8 @@ describe Imap::Backup::Downloader do
|
|
34
34
|
|
35
35
|
context "with failed fetches" do
|
36
36
|
specify "are skipped" do
|
37
|
-
allow(folder).to receive(:
|
38
|
-
expect(serializer).to_not receive(:save)
|
37
|
+
allow(folder).to receive(:fetch_multi) { nil }
|
38
|
+
expect(serializer).to_not receive(:save)
|
39
39
|
|
40
40
|
subject.run
|
41
41
|
end
|
@@ -132,13 +132,13 @@ describe Imap::Backup::Serializer::Mbox do
|
|
132
132
|
|
133
133
|
context "when adding the uid validity does not cause a name clash" do
|
134
134
|
it "renames the store, adding the existing uid validity" do
|
135
|
-
expect(store).to receive(:rename).with("folder
|
135
|
+
expect(store).to receive(:rename).with("folder-bbb")
|
136
136
|
|
137
137
|
subject.apply_uid_validity("aaa")
|
138
138
|
end
|
139
139
|
|
140
140
|
it "returns the new name" do
|
141
|
-
expect(subject.apply_uid_validity("aaa")).to eq("folder
|
141
|
+
expect(subject.apply_uid_validity("aaa")).to eq("folder-bbb")
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
@@ -146,13 +146,13 @@ describe Imap::Backup::Serializer::Mbox do
|
|
146
146
|
let(:exists) { true }
|
147
147
|
|
148
148
|
it "renames the store, adding the existing uid validity and a digit" do
|
149
|
-
expect(store).to receive(:rename).with("folder
|
149
|
+
expect(store).to receive(:rename).with("folder-bbb-1")
|
150
150
|
|
151
151
|
subject.apply_uid_validity("aaa")
|
152
152
|
end
|
153
153
|
|
154
154
|
it "returns the new name" do
|
155
|
-
expect(subject.apply_uid_validity("aaa")).to eq("folder
|
155
|
+
expect(subject.apply_uid_validity("aaa")).to eq("folder-bbb-1")
|
156
156
|
end
|
157
157
|
end
|
158
158
|
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: 5.
|
4
|
+
version: 5.2.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-02-
|
11
|
+
date: 2022-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -108,20 +108,6 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.0.0
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: codeclimate-test-reporter
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.4.8
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.4.8
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: pry-byebug
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,20 +136,6 @@ dependencies:
|
|
150
136
|
- - ">="
|
151
137
|
- !ruby/object:Gem::Version
|
152
138
|
version: 3.0.0
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: rspec_junit_formatter
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
139
|
- !ruby/object:Gem::Dependency
|
168
140
|
name: rubocop-rspec
|
169
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,6 +179,7 @@ files:
|
|
207
179
|
- docs/restore.md
|
208
180
|
- docs/setup.md
|
209
181
|
- imap-backup.gemspec
|
182
|
+
- lib/cli_coverage.rb
|
210
183
|
- lib/email/mboxrd/message.rb
|
211
184
|
- lib/email/provider.rb
|
212
185
|
- lib/email/provider/apple_mail.rb
|