Class: Imap::Backup::CLI::Local::Check
- Inherits:
-
Object
- Object
- Imap::Backup::CLI::Local::Check
- Includes:
- Helpers
- Defined in:
- lib/imap/backup/cli/local/check.rb
Overview
Runs integrity check on local backups
Instance Method Summary collapse
-
#initialize(options) ⇒ Check
constructor
A new instance of Check.
-
#run ⇒ void
Runs the check.
Methods included from Helpers
#account, included, #load_config, #requested_accounts
Constructor Details
#initialize(options) ⇒ Check
Returns a new instance of Check.
17 18 19 |
# File 'lib/imap/backup/cli/local/check.rb', line 17 def initialize() @options = end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Runs the check
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/imap/backup/cli/local/check.rb', line 23 def run results = requested_accounts(config).map do |account| serialized_folders = Account::SerializedFolders.new(account: account) folder_results = serialized_folders.map do |serializer, _folder| serializer.check_integrity! {name: serializer.folder, result: "OK"} rescue Serializer::FolderIntegrityError => e = e.to_s if [:delete_corrupt] serializer.delete << " and has been deleted" end { name: serializer.folder, result: } end {account: account.username, folders: folder_results} end case [:format] when "json" print_check_results_as_json(results) else print_check_results_as_text(results) end end |