]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Checking virtual alias files.
authorFrank Brehm <frank@brehm-online.com>
Tue, 23 May 2023 15:52:43 +0000 (17:52 +0200)
committerFrank Brehm <frank@brehm-online.com>
Tue, 23 May 2023 15:52:43 +0000 (17:52 +0200)
lib/pp_admintools/app/barracuda_sync.py

index 7d02519d993e7ddfe40d6c6854ee0f8e4c554869..6cb6642805c0baa7d5bdc4d160748981139c0ad0 100644 (file)
@@ -26,7 +26,7 @@ from fb_tools.xlate import format_list
 from .ldap import BaseLdapApplication
 from ..xlate import XLATOR
 
-__version__ = '0.6.4'
+__version__ = '0.6.5'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -292,6 +292,29 @@ class BarracudaSyncApp(BaseLdapApplication):
         """Check existence of given ."""
         LOG.debug(_('Checking all available virtual aliases table files ...'))
 
+        db_extension = self.postfix_filetype_extensions[self.postfix_db_hashtype]
+        if self.verbose > 1:
+            LOG.debug(_("Using file extension for db-files: {!r}.").format(db_extension))
+
+        for va_file in self.virtaliases_files:
+            db_file = va_file.parent / (va_file.name + db_extension)
+            if not db_file.exists() or not db_file.is_file():
+                LOG.error(_(
+                    "DB file for virtual aliases {!r} does not exists or is not a regular "
+                    "file.").format(str(db_file)))
+                self.virtaliases_files.remove(va_file)
+                continue
+            mtime_db_file = db_file.stat().st_mtime
+            mtime_va_file = va_file.stat().st_mtime
+            if mtime_db_file < mtime_va_file:
+                LOG.warn(_(
+                    "The last modification time of {db!r} is older than this "
+                    "of {va!r}.").format(db=str(db_file), va=str(va_file)))
+            elif self.verbose > 1:
+                LOG.debug(_(
+                     "The last modification time of {db!r} and {va!r} are "
+                     "okay.").format(db=str(db_file), va=str(va_file)))
+
     # -------------------------------------------------------------------------
     def _run(self):