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:
Chuck
2026-02-18 21:41:50 -05:00
parent 885fdeed62
commit c584f227c1
2 changed files with 11 additions and 5 deletions

View File

@@ -334,22 +334,26 @@ class TronbyteRepository:
'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.
Args:
app_id: App identifier
app_id: App identifier (directory name)
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:
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)
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:
output_path.parent.mkdir(parents=True, exist_ok=True)

View File

@@ -7558,7 +7558,9 @@ def install_from_tronbyte_repository():
temp_path = tmp.name
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:
return jsonify({'status': 'error', 'message': f'Failed to download app: {error}'}), 500