llama_load_model_from_url: fix compilation warning, clearer logging

This commit is contained in:
Pierrick HYMBERT 2024-03-16 18:01:55 +01:00
parent b0b49e0bb8
commit 545fef6e0e

View file

@ -1681,18 +1681,24 @@ struct llama_model * llama_load_model_from_url(const char * model_url, const cha
if (file_exists) { if (file_exists) {
auto * f_etag = fopen(etag_path, "r"); auto * f_etag = fopen(etag_path, "r");
if (f_etag) { if (f_etag) {
fgets(etag, sizeof(etag), f_etag); if (!fgets(etag, sizeof(etag), f_etag)) {
fprintf(stderr, "%s: unable to read file %s\n", __func__, etag_path);
} else {
fprintf(stderr, "%s: previous model file found %s: %s\n", __func__, etag_path, etag);
}
fclose(f_etag); fclose(f_etag);
fprintf(stderr, "%s: previous model .etag file found %s: %s\n", __func__, path_model, etag);
} }
auto * f_last_modified = fopen(last_modified_path, "r"); auto * f_last_modified = fopen(last_modified_path, "r");
if (f_last_modified) { if (f_last_modified) {
fgets(last_modified, sizeof(last_modified), f_last_modified); if (!fgets(last_modified, sizeof(last_modified), f_last_modified)) {
fclose(f_last_modified); fprintf(stderr, "%s: unable to read file %s\n", __func__, last_modified_path);
fprintf(stderr, "%s: previous model .lastModified file found %s: %s\n", __func__, last_modified_path, } else {
fprintf(stderr, "%s: previous model file found %s: %s\n", __func__, last_modified_path,
last_modified); last_modified);
} }
fclose(f_last_modified);
}
} }
// Send a HEAD request to retrieve the etag and last-modified headers // Send a HEAD request to retrieve the etag and last-modified headers