mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-14 14:33:00 +00:00
fix(starlark): use manifest filename field for .star downloads
Tronbyte apps don't always name their .star file to match the directory.
For example, the "analogclock" app has "analog_clock.star" (with underscore).
The manifest.yaml contains a "filename" field with the correct name.
Changes:
- download_star_file() now accepts optional filename parameter
- Install endpoint passes metadata['filename'] to download_star_file()
- Falls back to {app_id}.star if filename not in manifest
Fixes: "Failed to download .star file for analogclock" error
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -334,22 +334,26 @@ class TronbyteRepository:
|
|||||||
'cached': False
|
'cached': False
|
||||||
}
|
}
|
||||||
|
|
||||||
def download_star_file(self, app_id: str, output_path: Path) -> Tuple[bool, Optional[str]]:
|
def download_star_file(self, app_id: str, output_path: Path, filename: Optional[str] = None) -> Tuple[bool, Optional[str]]:
|
||||||
"""
|
"""
|
||||||
Download the .star file for an app.
|
Download the .star file for an app.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
app_id: App identifier
|
app_id: App identifier (directory name)
|
||||||
output_path: Where to save the .star file
|
output_path: Where to save the .star file
|
||||||
|
filename: Optional specific filename from manifest (e.g., "analog_clock.star")
|
||||||
|
If not provided, assumes {app_id}.star
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Tuple of (success, error_message)
|
Tuple of (success, error_message)
|
||||||
"""
|
"""
|
||||||
star_path = f"{self.APPS_PATH}/{app_id}/{app_id}.star"
|
# Use provided filename or fall back to app_id.star
|
||||||
|
star_filename = filename or f"{app_id}.star"
|
||||||
|
star_path = f"{self.APPS_PATH}/{app_id}/{star_filename}"
|
||||||
|
|
||||||
content = self._fetch_raw_file(star_path)
|
content = self._fetch_raw_file(star_path)
|
||||||
if not content:
|
if not content:
|
||||||
return False, f"Failed to download .star file for {app_id}"
|
return False, f"Failed to download .star file for {app_id} (tried {star_filename})"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|||||||
@@ -7558,7 +7558,9 @@ def install_from_tronbyte_repository():
|
|||||||
temp_path = tmp.name
|
temp_path = tmp.name
|
||||||
|
|
||||||
try:
|
try:
|
||||||
success, error = repo.download_star_file(data['app_id'], Path(temp_path))
|
# Pass filename from metadata (e.g., "analog_clock.star" for analogclock app)
|
||||||
|
filename = metadata.get('filename') if metadata else None
|
||||||
|
success, error = repo.download_star_file(data['app_id'], Path(temp_path), filename=filename)
|
||||||
if not success:
|
if not success:
|
||||||
return jsonify({'status': 'error', 'message': f'Failed to download app: {error}'}), 500
|
return jsonify({'status': 'error', 'message': f'Failed to download app: {error}'}), 500
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user