INNER CODE UNIT · Python

verify_destination_location

Minituff/nautical-backup · app/backup.py:152

    def verify_destination_location(self, dest_dir: Union[str, Path], create_if_not_exists=True) -> bool:
        """Verify the destination location (for containers) exists and is writable"""
        self.log_this(f"Verifying destination directory '{dest_dir}'...", "DEBUG", LogType.INIT)

        if not os.path.exists(dest_dir) and create_if_not_exists:
            os.makedirs(dest_dir, exist_ok=True)

        if not os.path.isdir(dest_dir):
            self.log_this(
                f"Destination directory '{dest_dir}' does not exist. Please mount it to /app/destination", "ERROR"
            )
            return False
        elif not os.access(dest_dir, os.R_OK):
            self.log_this(f"No read access to destination directory '{dest_dir}'.", "ERROR")
            return False
        elif not os.access(dest_dir, os.W_OK):
            self.log_this(f"No write access to destination directory '{dest_dir}'.", "ERROR")
            raise PermissionError(f"No write access to destination directory '{dest_dir}'")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…