1818namespace {
1919void ParseGguf (const DownloadItem& ggufDownloadItem,
2020 std::optional<std::string> author,
21- std::optional<std::string> name) {
21+ std::optional<std::string> name,
22+ std::optional<std::uint64_t > size) {
2223 namespace fs = std::filesystem;
2324 namespace fmu = file_manager_utils;
2425 config::GGUFHandler gguf_handler;
@@ -35,6 +36,7 @@ void ParseGguf(const DownloadItem& ggufDownloadItem,
3536 model_config.model = ggufDownloadItem.id ;
3637 model_config.name =
3738 name.has_value () ? name.value () : gguf_handler.GetModelConfig ().name ;
39+ model_config.size = size.value_or (0 );
3840 yaml_handler.UpdateModelConfig (model_config);
3941
4042 auto yaml_path{ggufDownloadItem.localPath };
@@ -284,8 +286,13 @@ cpp::result<DownloadTask, std::string> ModelService::HandleDownloadUrlAsync(
284286 }}}};
285287
286288 auto on_finished = [author, temp_name](const DownloadTask& finishedTask) {
289+ // Sum downloadedBytes from all items
290+ uint64_t model_size = 0 ;
291+ for (const auto & item : finishedTask.items ) {
292+ model_size = model_size + item.bytes .value_or (0 );
293+ }
287294 auto gguf_download_item = finishedTask.items [0 ];
288- ParseGguf (gguf_download_item, author, temp_name);
295+ ParseGguf (gguf_download_item, author, temp_name, model_size );
289296 };
290297
291298 downloadTask.id = unique_model_id;
@@ -349,8 +356,13 @@ cpp::result<std::string, std::string> ModelService::HandleUrl(
349356 }}}};
350357
351358 auto on_finished = [author](const DownloadTask& finishedTask) {
359+ // Sum downloadedBytes from all items
360+ uint64_t model_size = 0 ;
361+ for (const auto & item : finishedTask.items ) {
362+ model_size = model_size + item.bytes .value_or (0 );
363+ }
352364 auto gguf_download_item = finishedTask.items [0 ];
353- ParseGguf (gguf_download_item, author, std::nullopt );
365+ ParseGguf (gguf_download_item, author, std::nullopt , model_size );
354366 };
355367
356368 auto result = download_service_->AddDownloadTask (downloadTask, on_finished);
0 commit comments