lib,test: replace connection query() method with sync_exec{,_params}.
[mailshears.git] / lib / rm / plugins / dovecot.rb
1 require 'fileutils'
2
3 require 'common/dovecot_plugin'
4 require 'rm/rm_plugin'
5
6
7 # Handle the removal of users and domains from the Dovecot mailstore
8 # (the filesystem).
9 #
10 class DovecotRm
11
12 include DovecotPlugin
13 include RmPlugin
14
15
16 # Remove *domain* from the Dovecot mailstore. This just runs "rm -r"
17 # on the domain directory if it exists.
18 #
19 # @param domain [Domain] the domain to remove.
20 #
21 def remove_domain(domain)
22 domain_path = self.get_domain_path(domain)
23
24 if not File.directory?(domain_path)
25 raise NonexistentDomainError.new(domain.to_s())
26 end
27
28 FileUtils.rm_r(domain_path)
29 end
30
31
32 # Remove *user* from the Dovecot mailstore. This just runs "rm -r"
33 # on the *user*'s mailbox directory, if it exists.
34 #
35 # @param user [User] the user whose mailbox directory we want to
36 # remove.
37 #
38 def remove_user(user)
39 user_path = self.get_user_path(user)
40
41 if not File.directory?(user_path)
42 raise NonexistentUserError.new(user.to_s())
43 end
44
45 FileUtils.rm_r(user_path)
46 end
47
48 end