mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-02-14 10:19:54 +00:00
Fix ollama windows installer (#1894)
* Fix Windows filename issue in scheduled support bundles * Fix: Close temp file before executing Ollama installer on Windows Windows requires files to be closed before they can be executed. This fix ensures the temporary installer file is properly closed before attempting to run it, preventing file access errors on Windows systems.
This commit is contained in:
@@ -146,7 +146,7 @@ func (h *OllamaHelper) downloadAndInstallWindows() error {
|
|||||||
return errors.Wrap(err, "failed to create temporary file")
|
return errors.Wrap(err, "failed to create temporary file")
|
||||||
}
|
}
|
||||||
defer os.Remove(tmpFile.Name())
|
defer os.Remove(tmpFile.Name())
|
||||||
defer tmpFile.Close()
|
defer tmpFile.Close() // Ensures file is closed in error paths
|
||||||
|
|
||||||
// Download installer
|
// Download installer
|
||||||
resp, err := http.Get(h.downloadURL)
|
resp, err := http.Get(h.downloadURL)
|
||||||
@@ -165,6 +165,13 @@ func (h *OllamaHelper) downloadAndInstallWindows() error {
|
|||||||
return errors.Wrap(err, "failed to write installer")
|
return errors.Wrap(err, "failed to write installer")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close the file before executing it (required on Windows)
|
||||||
|
// Note: This will be called twice (here and via defer), but that's safe
|
||||||
|
// The defer ensures cleanup on error paths, this ensures closure before execution
|
||||||
|
if err := tmpFile.Close(); err != nil {
|
||||||
|
return errors.Wrap(err, "failed to close installer file")
|
||||||
|
}
|
||||||
|
|
||||||
// Run installer
|
// Run installer
|
||||||
klog.Info("Running Ollama installer...")
|
klog.Info("Running Ollama installer...")
|
||||||
cmd := exec.Command(tmpFile.Name())
|
cmd := exec.Command(tmpFile.Name())
|
||||||
|
|||||||
Reference in New Issue
Block a user