imap-backup 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,6 +23,9 @@ module Imap
23
23
  message = @connection.imap.uid_fetch([uid.to_i], REQUESTED_ATTRIBUTES)[0][1]
24
24
  message['RFC822'].force_encoding('utf-8') if RUBY_VERSION > '1.9'
25
25
  message
26
+ rescue Net::IMAP::NoResponseError => e
27
+ warn "Folder '#{@folder}' does not exist"
28
+ nil
26
29
  end
27
30
  end
28
31
  end
@@ -13,6 +13,7 @@ module Imap
13
13
  uids = @folder.uids - @serializer.uids
14
14
  uids.each do |uid|
15
15
  message = @folder.fetch(uid)
16
+ next if message.nil?
16
17
  @serializer.save(uid, message)
17
18
  end
18
19
  end
@@ -2,7 +2,7 @@ module Imap
2
2
  module Backup
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- REVISION = 2
5
+ REVISION = 3
6
6
  VERSION = [MAJOR, MINOR, REVISION].map(&:to_s).join('.')
7
7
  end
8
8
  end
@@ -4,6 +4,10 @@ require 'spec_helper'
4
4
  describe Imap::Backup::Account::Folder do
5
5
  include InputOutputTestHelpers
6
6
 
7
+ let(:missing_mailbox_data) { stub('Data', :text => 'Unknown Mailbox: my_folder') }
8
+ let(:missing_mailbox_response) { stub('Response', :data => missing_mailbox_data) }
9
+ let(:missing_mailbox_error) { Net::IMAP::NoResponseError.new(missing_mailbox_response) }
10
+
7
11
  context 'with instance' do
8
12
  before :each do
9
13
  @imap = stub('Net::IMAP')
@@ -21,13 +25,10 @@ describe Imap::Backup::Account::Folder do
21
25
  end
22
26
 
23
27
  it 'returns an empty array for missing mailboxes' do
24
- data = stub('Data', :text => 'Unknown Mailbox: my_folder')
25
- response = stub('Response', :data => data)
26
- error = Net::IMAP::NoResponseError.new(response)
27
28
  @imap.
28
29
  should_receive(:examine).
29
30
  with('my_folder').
30
- and_raise(error)
31
+ and_raise(missing_mailbox_error)
31
32
 
32
33
  capturing_output do
33
34
  expect(subject.uids).to eq([])
@@ -53,6 +54,17 @@ describe Imap::Backup::Account::Folder do
53
54
  subject.fetch(123)
54
55
  end
55
56
 
57
+ it "returns nil if the mailbox doesn't exist" do
58
+ @imap.
59
+ should_receive(:examine).
60
+ with('my_folder').
61
+ and_raise(missing_mailbox_error)
62
+
63
+ capturing_output do
64
+ expect(subject.fetch(123)).to be_nil
65
+ end
66
+ end
67
+
56
68
  if RUBY_VERSION > '1.9'
57
69
  it 'should set the encoding on the message' do
58
70
  @imap.stub!(:examine => nil, :uid_fetch => [[nil, @message]])
@@ -42,6 +42,13 @@ describe Imap::Backup::Downloader do
42
42
  subject.run
43
43
  end
44
44
 
45
+ it 'skips failed fetches' do
46
+ @folder.should_receive(:fetch).with('999').and_return(nil)
47
+ @serializer.should_not_receive(:save).with('999', anything)
48
+
49
+ subject.run
50
+ end
51
+
45
52
  context 'to download' do
46
53
  before :each do
47
54
  @serializer.stub!(:exist?) do |uid|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imap-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -187,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
187
  version: '0'
188
188
  segments:
189
189
  - 0
190
- hash: -2027383479193417702
190
+ hash: 1167713560722086376
191
191
  required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  none: false
193
193
  requirements:
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  segments:
198
198
  - 0
199
- hash: -2027383479193417702
199
+ hash: 1167713560722086376
200
200
  requirements: []
201
201
  rubyforge_project:
202
202
  rubygems_version: 1.8.23