VirtualMailManager/mailbox.py
branchv0.7.x
changeset 642 4cd9d0a9f42f
parent 568 14abdd04ddf5
child 643 df1e3b67882a
equal deleted inserted replaced
641:724ac0a4068d 642:4cd9d0a9f42f
   204 
   204 
   205     def _subscribe_boxes(self):
   205     def _subscribe_boxes(self):
   206         """Writes all created mailboxes to the subscriptions file."""
   206         """Writes all created mailboxes to the subscriptions file."""
   207         if not self._boxes:
   207         if not self._boxes:
   208             return
   208             return
   209         subscriptions = open('subscriptions', 'w')
   209         with open('subscriptions', 'w') as subscriptions:
   210         subscriptions.write('\n'.join(self._boxes))
   210             subscriptions.write('\n'.join(self._boxes))
   211         subscriptions.write('\n')
   211             subscriptions.write('\n')
   212         subscriptions.flush()
       
   213         subscriptions.close()
       
   214         os.chown('subscriptions', self._user.uid, self._user.gid)
   212         os.chown('subscriptions', self._user.uid, self._user.gid)
   215         os.chmod('subscriptions', self.__class__.FILE_MODE)
   213         os.chmod('subscriptions', self.__class__.FILE_MODE)
   216         del self._boxes[:]
   214         del self._boxes[:]
   217 
   215 
   218     def _add_boxes(self, mailboxes, subscribe):
   216     def _add_boxes(self, mailboxes, subscribe):