Skip to content

local_version_service

appimage_updater.core.local_version_service

Service for determining current installed version from local files.

This module provides centralized logic for determining the current version of an installed application using multiple strategies in priority order.

LocalVersionService(version_parser=None, info_service=None)

Service for determining current installed version from local files.

Source code in src/appimage_updater/core/local_version_service.py
def __init__(self, version_parser: VersionParser | None = None, info_service: InfoFileService | None = None):
    """Initialize with optional dependencies for testing."""
    self.version_parser = version_parser or VersionParser()
    self.info_service = info_service or InfoFileService()

info_service = info_service or InfoFileService() instance-attribute

version_parser = version_parser or VersionParser() instance-attribute

get_current_version(app_config)

Get current version using priority: .info -> .current -> filename analysis.

Parameters:

Name Type Description Default
app_config ApplicationConfig

Application configuration

required

Returns:

Type Description
str | None

Current version string or None if not determinable

Source code in src/appimage_updater/core/local_version_service.py
def get_current_version(self, app_config: ApplicationConfig) -> str | None:
    """Get current version using priority: .info -> .current -> filename analysis.

    Args:
        app_config: Application configuration

    Returns:
        Current version string or None if not determinable
    """
    # Strategy 1: Try to get version from .info file
    version = self._get_version_from_info_file(app_config)
    if version:
        logger.debug(f"Found version from .info file: {version}")
        return version

    # Strategy 2: Try to parse version from .current file (if exists)
    version = self._get_version_from_current_file(app_config)
    if version:
        logger.debug(f"Found version from .current file: {version}")
        return version

    # Strategy 3: Analyze existing AppImage files to determine current version
    version = self._get_version_from_files(app_config)
    if version:
        logger.debug(f"Found version from file analysis: {version}")
        return version

    logger.debug("No current version could be determined")
    return None