imap-backup 1.0.15 → 1.0.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3d7f421192f5e5b15efcb55aa13b55cd769899e
4
- data.tar.gz: d98f149a116634df9e6aa79898da5e2c61ac770a
3
+ metadata.gz: 87979e52b9e7629fc1b5a90e2567e795a36cc89c
4
+ data.tar.gz: 286d05d106efb19a22bda37446154531a396fe41
5
5
  SHA512:
6
- metadata.gz: 7173984ab8c9ef01013d2d6468097aa7b928b59cf12b363b66b3119074f26996c80ffac4c27b36499cd739132eb4105d6f4c0fbd917ee53df69e90f34918a533
7
- data.tar.gz: 3f5a4e52b736fabb1404ffa0b4ed01ff22b83a1c706f6de90c96f68b66fecaf22eed6af251b674c519dcb2e235aaca56d1b074a347a9a4ec54fb7c6a410e92e2
6
+ metadata.gz: 19e5fecd98e2bedb65b4da2fca103a65baedf04627e5ed83aacabf3b2408b4c4f2b1e0bc2a267705e2acad0d6ecc303c5db15d555759162a2b7356cf24086bcc
7
+ data.tar.gz: 9f4a7e727c2a544271846cd541adf9e4cd57d190eb31d09c198bf95f242b3d20fcfaac6376f92809ff9887c88432ba7340ad0a8f830e323106d99d1fa657a4be
data/README.md CHANGED
@@ -53,7 +53,7 @@ It creates ~/.imap-backup directory and configuration file. E.g.:
53
53
  It connects to GMail by default, but you can also specify a server:
54
54
 
55
55
  ```json
56
- {
56
+ {
57
57
  "accounts":
58
58
  [
59
59
  {
@@ -68,7 +68,7 @@ It connects to GMail by default, but you can also specify a server:
68
68
  ]
69
69
  }
70
70
  ]
71
- }
71
+ }
72
72
  ```
73
73
 
74
74
  ## Google Apps
@@ -101,6 +101,23 @@ Each folder is saved to an mbox file.
101
101
  Alongside each mbox is a file with extension '.imap', which lists the source IMAP
102
102
  UIDs to allow a full restore.
103
103
 
104
+ # Troubleshooting
105
+
106
+ If you have problems:
107
+
108
+ 1. ensure that you have the latest release,
109
+ 2. turn on debugging output:
110
+
111
+ ```json
112
+ {
113
+ "accounts":
114
+ [
115
+ ...
116
+ ],
117
+ "debug": true
118
+ }
119
+ ```
120
+
104
121
  # Other Usage
105
122
 
106
123
  List IMAP folders:
@@ -126,6 +143,7 @@ $ imap-backup status
126
143
  * https://github.com/thefloweringash/gmail-imap-backup
127
144
  * https://github.com/mleonhard/imapbackup
128
145
  * https://github.com/rgrove/larch - copies between IMAP servers
146
+ * https://github.com/OfflineIMAP/offlineimap
129
147
 
130
148
  ## Contributing
131
149
 
@@ -38,7 +38,7 @@ module Imap::Backup
38
38
  # start the connection so we get logging messages in the right order
39
39
  imap
40
40
  backup_folders.each do |folder|
41
- Imap::Backup.logger.debug "Folder: #{folder[:name]}"
41
+ Imap::Backup.logger.debug "[#{folder[:name]}] running backup"
42
42
  f = Account::Folder.new(self, folder[:name])
43
43
  s = Serializer::Mbox.new(local_path, folder[:name])
44
44
  d = Downloader.new(f, s)
@@ -61,6 +61,7 @@ module Imap::Backup
61
61
  @imap = Net::IMAP.new(server, options)
62
62
  Imap::Backup.logger.debug "Logging in: #{username}/#{masked_password}"
63
63
  @imap.login(username, password)
64
+ Imap::Backup.logger.debug "Login complete"
64
65
  @imap
65
66
  end
66
67
 
@@ -10,29 +10,34 @@ module Imap::Backup
10
10
  REQUESTED_ATTRIBUTES = ['RFC822', 'FLAGS', 'INTERNALDATE']
11
11
 
12
12
  attr_reader :connection
13
- attr_reader :folder
13
+ attr_reader :name
14
14
 
15
15
  delegate imap: :connection
16
16
 
17
- def initialize(connection, folder)
18
- @connection, @folder = connection, folder
17
+ def initialize(connection, name)
18
+ @connection = connection
19
+ @name = name
20
+ end
21
+
22
+ def folder
23
+ name
19
24
  end
20
25
 
21
26
  def uids
22
- imap.examine(folder)
27
+ imap.examine(name)
23
28
  imap.uid_search(['ALL']).sort
24
29
  rescue Net::IMAP::NoResponseError => e
25
- Imap::Backup.logger.warn "Folder '#{folder}' does not exist"
30
+ Imap::Backup.logger.warn "Folder '#{name}' does not exist"
26
31
  []
27
32
  end
28
33
 
29
34
  def fetch(uid)
30
- imap.examine(folder)
35
+ imap.examine(name)
31
36
  message = imap.uid_fetch([uid.to_i], REQUESTED_ATTRIBUTES)[0][1]
32
37
  message['RFC822'].force_encoding('utf-8') if RUBY_VERSION > '1.9'
33
38
  message
34
39
  rescue Net::IMAP::NoResponseError => e
35
- Imap::Backup.logger.warn "Folder '#{folder}' does not exist"
40
+ Imap::Backup.logger.warn "Folder '#{name}' does not exist"
36
41
  nil
37
42
  end
38
43
  end
@@ -13,10 +13,14 @@ module Imap::Backup
13
13
 
14
14
  def run
15
15
  uids = folder.uids - serializer.uids
16
- Imap::Backup.logger.debug "New messages: #{uids.count}"
16
+ Imap::Backup.logger.debug "[#{folder.name}] #{uids.count} new messages"
17
17
  uids.each do |uid|
18
18
  message = folder.fetch(uid)
19
- next if message.nil?
19
+ if message.nil?
20
+ Imap::Backup.logger.debug "[#{folder.name}] #{uid} - not available - skipped"
21
+ next
22
+ end
23
+ Imap::Backup.logger.debug "[#{folder.name}] #{uid} - #{message["RFC822"].size} bytes"
20
24
  serializer.save(uid, message)
21
25
  end
22
26
  end
@@ -6,6 +6,9 @@ module Imap::Backup
6
6
  FILE_PERMISSIONS = 0600
7
7
 
8
8
  class Base
9
+ attr_reader :path
10
+ attr_reader :folder
11
+
9
12
  def initialize(path, folder)
10
13
  @path, @folder = path, folder
11
14
  Utils.check_permissions(@path, DIRECTORY_PERMISSIONS)
@@ -29,7 +29,10 @@ module Imap::Backup
29
29
 
30
30
  def save(uid, message)
31
31
  uid = uid.to_s
32
- return if uids.include?(uid)
32
+ if uids.include?(uid)
33
+ Imap::Backup.logger.debug "[#{folder}] message #{uid} already downloaded - skipping"
34
+ return
35
+ end
33
36
  body = message['RFC822']
34
37
  mboxrd_message = Email::Mboxrd::Message.new(body)
35
38
  mbox = imap = nil
@@ -39,7 +42,7 @@ module Imap::Backup
39
42
  mbox.write mboxrd_message.to_s
40
43
  imap.write uid + "\n"
41
44
  rescue => e
42
- Imap::Backup.logger.warn "Failed to save message #{uid}:\n#{body}. #{e}"
45
+ Imap::Backup.logger.warn "[#{folder}] failed to save message #{uid}:\n#{body}. #{e}"
43
46
  ensure
44
47
  mbox.close if mbox
45
48
  imap.close if imap
@@ -3,6 +3,6 @@ module Imap; end
3
3
  module Imap::Backup
4
4
  MAJOR = 1
5
5
  MINOR = 0
6
- REVISION = 15
6
+ REVISION = 16
7
7
  VERSION = [MAJOR, MINOR, REVISION].map(&:to_s).join('.')
8
8
  end
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
 
4
4
  describe Imap::Backup::Downloader do
5
5
  describe '#run' do
6
- let(:message) { 'message' }
7
- let(:folder) { double('Imap::Backup::Account::Folder', :fetch => message) }
6
+ let(:message) { {'RFC822' => 'blah'} }
7
+ let(:folder) { double('Imap::Backup::Account::Folder', :fetch => message, :name => 'folder') }
8
8
  let(:folder_uids) { ['111', '222', '333'] }
9
9
  let(:serializer) { double('Imap::Backup::Serializer', :save => nil) }
10
10
  let(:serializer_uids) { ['222'] }
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: 1.0.15
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Yates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-14 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake