]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/rm/plugins/dovecot_mailstore.rb
8ab507d674c3c77739d854ad9d95439b702531ee
4 require 'common/filesystem'
5 require 'common/mailstore'
6 require 'common/dovecot_mailstore_plugin'
9 class DovecotMailstoreRm
< Mailstore
11 include DovecotMailstorePlugin
15 def delete_domain(domain
)
16 domain_path
= self.get_domain_path(domain
)
17 FileUtils
.rm_r(domain_path
)
20 def delete_account(account
)
21 account_path
= self.get_account_path(account
)
22 FileUtils
.rm_r(account_path
)
25 def get_leftover_domains(db_domains
)
26 # Get the list of domains according to the filesystem.
27 fs_domains
= self.get_domains_from_filesystem()
29 # Return the list of domains on the filesystem that aren't in the DB.
30 return (fs_domains
- db_domains
)
33 def get_leftover_accounts(db_accounts
)
34 # Get the list of accounts according to the filesystem.
35 fs_domains
= self.get_domains_from_filesystem()
36 fs_accounts
= self.get_accounts_from_filesystem(fs_domains
)
38 # And return the accounts on the filesystem that aren't in the DB.
39 return (fs_accounts
- db_accounts
)
43 def get_domain_usernames(domain
)
44 return get_accounts_from_filesystem([domain
])
49 def get_domains_from_filesystem()
50 return Filesystem
.get_subdirs(@domain_root)
53 def get_accounts_from_filesystem(domains
)
56 domains
.each
do |domain
|
58 # Throws a NonexistentDomainError if the domain's path
59 # doesn't exist on the filesystem. In this case, we want
60 # to report zero accounts.
61 domain_path
= get_domain_path(domain
)
62 usernames
= Filesystem
.get_subdirs(domain_path
)
64 usernames
.each
do |username
|
65 accounts
<< "#{username}@#{domain}"
67 rescue NonexistentDomainError