MCPcopy Create free account
hub / github.com/FastLED/FastLED / handle_zip_artifact

Function handle_zip_artifact

ci/compiler/platformio_cache.py:723–857  ·  view source on GitHub ↗

Enhanced artifact handler with validation and error recovery. Returns the resolved local path for the artifact.

(
    zip_source: str,
    cache_manager: PlatformIOCache,
    env_section: str,
)

Source from the content-addressed store, hash-verified

721
722
723def handle_zip_artifact(
724 zip_source: str,
725 cache_manager: PlatformIOCache,
726 env_section: str,
727) -> str:
728 """
729 Enhanced artifact handler with validation and error recovery.
730 Returns the resolved local path for the artifact.
731 """
732 try:
733 # Download and cache the artifact
734 cached_zip_path = cache_manager.download_artifact(zip_source)
735
736 if not cached_zip_path or not Path(cached_zip_path).exists():
737 raise FileNotFoundError(f"Download failed for {zip_source}")
738
739 # Extract and get the content path
740 cache_key = cache_manager._get_cache_key(zip_source)
741 cached_zip_path_obj = Path(cached_zip_path)
742
743 # Extract to a directory alongside the zip file
744 artifact_dir = cached_zip_path_obj.parent
745 extracted_dir = artifact_dir / "extracted"
746 temp_unzip_dir = artifact_dir / "temp_extract"
747
748 # Check if already extracted
749 if extracted_dir.exists():
750 # Validate existing extraction and auto-detect type
751 manifest_result = validate_and_detect_manifest(extracted_dir)
752 if manifest_result.is_valid:
753 print(f"Using existing extraction: {extracted_dir}")
754
755 # Check for completion status using URL-based cache key (consistent with status file creation)
756 url_cache_key = cache_manager._get_cache_key(zip_source)
757 status_file = _get_status_file(artifact_dir, url_cache_key)
758 if _is_processing_complete(status_file):
759 print(
760 f"Skipping PlatformIO installation for {env_section}: found completion status"
761 )
762 return get_proper_file_url(extracted_dir)
763
764 # Create a session cache key for this artifact
765 session_cache_key = f"{'framework' if manifest_result.is_framework else 'platform'}:{get_platformio_command_path(extracted_dir)}"
766
767 # If we've already handled this exact artifact in this session, skip PlatformIO entirely
768 if session_cache_key in _session_installation_cache:
769 print(
770 f"Skipping PlatformIO installation for {env_section}: already processed in this session"
771 )
772 return get_proper_file_url(extracted_dir)
773
774 # Otherwise, install via PlatformIO
775 install_success = install_with_platformio(
776 extracted_dir, manifest_result.is_framework, env_section
777 )
778 # Status file will be created later using URL-based cache key
779
780 if install_success:

Callers 3

optimizeMethod · 0.90
optimize_enhancedMethod · 0.90
_process_artifactFunction · 0.85

Calls 15

_get_status_fileFunction · 0.85
_is_processing_completeFunction · 0.85
get_proper_file_urlFunction · 0.85
install_with_platformioFunction · 0.85
listClass · 0.85
_write_statusFunction · 0.85
download_artifactMethod · 0.80
_get_cache_keyMethod · 0.80
warningMethod · 0.80

Tested by

no test coverage detected