Skip to content

Conversation

npopov-vst
Copy link
Contributor

llama-run: Fix model download on Windows

  • fix SSL error (SSL peer certificate or SSH remote key was not OK)
  • fix program crash on std::filesystem::rename

 * fix SSL error (SSL peer certificate or SSH remote key was not OK)
 * fix program crash on std::filesystem::rename
@ericcurtin
Copy link
Collaborator

Thanks for the fix

I am going to split out the curl stuff in common/arg.cpp to a common/curl.cpp class

We should try and consolidate the llama-run specific stuff more in common/arg.cpp to help avoid things like this.

if (!output_file.empty()) {
// Explicitly close file in order to release lock
out.close();
std::filesystem::rename(output_file_partial, output_file);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if we put 412-447 into it's own function and relied on RAII to close the file. We would call this function in init and then:

if (!output_file.empty()) {
    std::filesystem::rename(output_file_partial, output_file);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks! Yeah, I have created a separated method to utilize RAII.

@ericcurtin ericcurtin requested a review from Copilot September 14, 2025 20:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes two critical issues affecting model downloads on Windows in the llama-run tool: SSL certificate verification errors and crashes during file operations. The changes reorganize the download logic to use temporary files properly and add Windows-specific SSL configuration.

  • Restructures the HttpClient class to handle temporary file operations in the public init method
  • Adds Windows-specific SSL configuration to use native certificate authority
  • Moves file renaming from download completion to the main download flow

}

if (!output_file.empty()) {
std::filesystem::rename(output_file_partial, output_file);
Copy link
Preview

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The std::filesystem::rename call lacks error handling. On Windows, this operation can fail due to file permissions, antivirus software, or if the target file is still open. Consider wrapping this in a try-catch block and providing appropriate error handling or retry logic.

Suggested change
std::filesystem::rename(output_file_partial, output_file);
try {
std::filesystem::rename(output_file_partial, output_file);
} catch (const std::filesystem::filesystem_error& e) {
printe("Error: Failed to rename '%s' to '%s': %s\n", output_file_partial.c_str(), output_file.c_str(), e.what());
return -1;
}

Copilot uses AI. Check for mistakes.

CURL * curl = nullptr;
struct curl_slist * chunk = nullptr;


Copy link
Preview

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace on line 476 should be removed to maintain code cleanliness.

Suggested change

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

@ericcurtin ericcurtin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and clean

@ericcurtin
Copy link
Collaborator

Build failures unrelated

@ericcurtin ericcurtin merged commit 28c39da into ggml-org:master Sep 15, 2025
47 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants