- def mv_domain(from, to)
- from_path = self.get_domain_path(from)
- to_path = self.get_domain_path(to)
- FileUtils.mv(from_path, to_path)
- end
+ # get_user_path() will fail if there's no mailbox to move. It will
+ # also fail on an invalid user -- oh well!
+ begin
+ from_path = self.get_user_path(user_from)
+ rescue NonexistentUserError
+ # Do nothing, there's no source mailbox...
+ return
+ end
+
+ # We may need to create the target domain directory, even if the
+ # domain exists in the database.
+ domain_to = user_to.split('@')[1]
+ domain_dir = self.get_domain_path(domain_to)
+ FileUtils.mkdir_p(domain_dir)