imap-backup 9.0.0 → 9.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3daac577a7328b73a4593e677826b2f168f7565487595a04b37504b863dccd46
4
- data.tar.gz: 3290089c8c67f31d7dc7cfc53ca6c6d2dd20328727447b2164273409408d36d5
3
+ metadata.gz: b2482ddc0519b2eb1b1160cee2aae34befdb8faa4acf9de2127be214bac3907f
4
+ data.tar.gz: 2ed7b7b25497ee53cdfd1735628401076defaee63829aa9bfabd5fc483e69a28
5
5
  SHA512:
6
- metadata.gz: df10381df343a5c4c08d8fa39310a6593b6383608926d360202feb92652bc2ad42bbeffc306789e6f4761bc06405cb2b8d51efe76e65cfc5a9507d397d36e2ae
7
- data.tar.gz: 05a4d8b9941622fc56f68e952f71b38383a9593fe6abedb64d6c4b1a5670eee0ca2c40a27cc14a7d05d298638e3c242f056b3a8b68288a61dafae8449f51e36b
6
+ metadata.gz: a7a6790a9354d9c06eedb72b2a6bf1960ed691a53c95b4a11c0ce50359ca397e0929240b2eafc93365610f43588c190515367462c4cde3ccf58242d5afd31622
7
+ data.tar.gz: 6270491bbc12302365de92b666b438b3638baa67d162f01e0b825deef73544f349919b779d6f4ea3db4dc3e570b3d27ede88e108667745b811596c9214fd205f
data/docs/development.md CHANGED
@@ -64,7 +64,7 @@ fetch_data_items = imap.uid_fetch(uids, ["BODY[]"])
64
64
  # Older Ruby Versions
65
65
 
66
66
  Dockerfiles are available for all the supported Ruby versions,
67
- see the `docker` directory.
67
+ see the `container` directory.
68
68
 
69
69
  # Contributing
70
70
 
@@ -14,24 +14,24 @@ module Imap::Backup
14
14
  def run
15
15
  all_names = Account::Connection::FolderNames.new(client: client, account: account).run
16
16
 
17
- names =
18
- if account.folders&.any?
17
+ configured =
18
+ case
19
+ when account.folders&.any?
19
20
  account.folders.map { |af| af[:name] }
21
+ when account.folder_blacklist
22
+ []
20
23
  else
21
24
  all_names
22
25
  end
23
26
 
24
- all_names.map do |name|
25
- backup =
26
- if account.folder_blacklist
27
- !names.include?(name)
28
- else
29
- names.include?(name)
30
- end
31
- next if !backup
27
+ names =
28
+ if account.folder_blacklist
29
+ all_names - configured
30
+ else
31
+ all_names & configured
32
+ end
32
33
 
33
- Account::Folder.new(account.connection, name)
34
- end.compact
34
+ names.map { |name| Account::Folder.new(account.connection, name) }
35
35
  end
36
36
  end
37
37
  end
@@ -75,14 +75,7 @@ module Imap::Backup
75
75
  When one or other account uses a delimiter other than `/` (i.e. `.`),
76
76
  use the `--source-delimiter=` and/or `--destination-delimiter=` options.
77
77
 
78
- Usually, you should migrate to an account with empty folders.
79
-
80
- Before migrating each folder, `imap-backup` checks if the destination
81
- folder is empty.
82
-
83
- If it finds a non-empty destination folder, it halts with an error.
84
-
85
- If you are sure that these destination emails can be deleted,
78
+ If you you want to delete existing emails in destination folders,
86
79
  use the `--reset` option. In this case, all existing emails are
87
80
  deleted before uploading the migrated emails.
88
81
  DESC
@@ -13,7 +13,7 @@ module Imap::Backup
13
13
  def run
14
14
  count = serializer.uids.count
15
15
  folder.create
16
- ensure_destination_empty!
16
+ folder.clear if reset
17
17
 
18
18
  Logger.logger.debug "[#{folder.name}] #{count} to migrate"
19
19
  serializer.each_message(serializer.uids).with_index do |message, i|
@@ -31,25 +31,5 @@ module Imap::Backup
31
31
  end
32
32
  end
33
33
  end
34
-
35
- private
36
-
37
- def ensure_destination_empty!
38
- if reset
39
- folder.clear
40
- else
41
- fail_if_destination_not_empty!
42
- end
43
- end
44
-
45
- def fail_if_destination_not_empty!
46
- return if folder.uids.empty?
47
-
48
- raise <<~ERROR
49
- The destination folder '#{folder.name}' is not empty.
50
- Pass the --reset flag if you want to clear existing emails from destination
51
- folders before uploading.
52
- ERROR
53
- end
54
34
  end
55
35
  end
@@ -33,14 +33,24 @@ module Imap::Backup
33
33
  end
34
34
 
35
35
  def source_uid(destination_uid)
36
+ if destination_store == {}
37
+ raise "Assign UID validities with #reset before calling #source_uid"
38
+ end
39
+
36
40
  map.key(destination_uid)
37
41
  end
38
42
 
39
43
  def destination_uid(source_uid)
44
+ if destination_store == {}
45
+ raise "Assign UID validities with #reset before calling #destination_uid"
46
+ end
47
+
40
48
  map[source_uid]
41
49
  end
42
50
 
43
51
  def map_uids(source:, destination:)
52
+ raise "Assign UID validities with #reset before calling #map_uids" if destination_store == {}
53
+
44
54
  map[source] = destination
45
55
  end
46
56
 
@@ -3,7 +3,7 @@ module Imap; end
3
3
  module Imap::Backup
4
4
  MAJOR = 9
5
5
  MINOR = 0
6
- REVISION = 0
6
+ REVISION = 2
7
7
  PRE = nil
8
8
  VERSION = [MAJOR, MINOR, REVISION, PRE].compact.map(&:to_s).join(".")
9
9
  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: 9.0.0
4
+ version: 9.0.2
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-12-29 00:00:00.000000000 Z
11
+ date: 2023-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline