()
| 139 | * so ephemeral containers can access marketplaces without re-cloning. |
| 140 | */ |
| 141 | export async function syncMarketplacesToZipCache(): Promise<void> { |
| 142 | // Read-only iteration — Safe variant so a corrupted config doesn't throw. |
| 143 | // This runs during startup paths; a throw here cascades to the same |
| 144 | // try-block that catches loadAllPlugins failures. |
| 145 | const knownMarketplaces = await loadKnownMarketplacesConfigSafe() |
| 146 | |
| 147 | // Save marketplace JSONs to zip cache |
| 148 | for (const [name, entry] of Object.entries(knownMarketplaces)) { |
| 149 | if (!entry.installLocation) continue |
| 150 | try { |
| 151 | await saveMarketplaceJsonToZipCache(name, entry.installLocation) |
| 152 | } catch (error) { |
| 153 | logForDebugging(`Failed to save marketplace JSON for ${name}: ${error}`) |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | // Merge with previously cached data (ephemeral containers lose global config) |
| 158 | const zipCacheKnownMarketplaces = await readZipCacheKnownMarketplaces() |
| 159 | const mergedKnownMarketplaces: KnownMarketplacesFile = { |
| 160 | ...zipCacheKnownMarketplaces, |
| 161 | ...knownMarketplaces, |
| 162 | } |
| 163 | await writeZipCacheKnownMarketplaces(mergedKnownMarketplaces) |
| 164 | } |
no test coverage detected