Skip to content

Commit c187b16

Browse files
authored
fix(gallery): clean up partially downloaded backend on installation failure (mudler#8679)
When a backend download fails (e.g., on Mac OS with port conflicts causing connection issues), the backend directory is left with partial files. This causes subsequent installation attempts to fail with 'run file not found' because the sanity check runs on an empty/partial directory. This fix cleans up the backend directory when the initial download fails before attempting fallback URIs or mirrors. This ensures a clean state for retry attempts. Fixes: mudler#8016 Signed-off-by: localai-bot <localai-bot@users.noreply.github.com> Co-authored-by: localai-bot <localai-bot@users.noreply.github.com>
1 parent 42e580b commit c187b16

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

core/gallery/backends.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ func InstallBackend(ctx context.Context, systemState *system.SystemState, modelL
202202
} else {
203203
xlog.Debug("Downloading backend", "uri", config.URI, "backendPath", backendPath)
204204
if err := uri.DownloadFileWithContext(ctx, backendPath, "", 1, 1, downloadStatus); err != nil {
205+
// Clean up the partially downloaded backend directory on failure
206+
xlog.Debug("Backend download failed, cleaning up", "backendPath", backendPath, "error", err)
207+
if cleanupErr := os.RemoveAll(backendPath); cleanupErr != nil {
208+
xlog.Warn("Failed to clean up backend directory", "backendPath", backendPath, "error", cleanupErr)
209+
}
210+
205211
success := false
206212
// Try to download from mirrors
207213
for _, mirror := range config.Mirrors {

0 commit comments

Comments
 (0)