Called on application shutdown to encrypt the database.
(self)
| 809 | raise |
| 810 | |
| 811 | def shutdown_encrypt(self): |
| 812 | """Called on application shutdown to encrypt the database.""" |
| 813 | if not self.is_configured(): |
| 814 | return |
| 815 | if not self._fernet_key: |
| 816 | logger.warning("No Fernet key at shutdown - DB may not be encrypted") |
| 817 | return |
| 818 | |
| 819 | try: |
| 820 | self._close_db() |
| 821 | time.sleep(0.2) |
| 822 | if os.path.exists(self.main_db_path): |
| 823 | self.encrypt_database() |
| 824 | logger.info("Database encrypted on shutdown") |
| 825 | except Exception as e: |
| 826 | logger.error(f"Shutdown encryption failed: {e}") |
| 827 | |
| 828 | # ========================================================================= |
| 829 | # CRASH RECOVERY |
no test coverage detected