diff --git a/common/download.cpp b/common/download.cpp index 8aa175a07d..02f5c87082 100644 --- a/common/download.cpp +++ b/common/download.cpp @@ -346,10 +346,6 @@ static int common_download_file_single_online(const std::string & url, const std::string path_temporary = path + ".downloadInProgress"; int delay = retry_delay_seconds; - if (opts.callback) { - opts.callback->on_start(p); - } - for (int i = 0; i < max_attempts; ++i) { if (opts.callback && opts.callback->is_cancelled()) { break; @@ -373,6 +369,12 @@ static int common_download_file_single_online(const std::string & url, p.downloaded = existing_size; + if (i == 0 && opts.callback) { + // report after the resume offset is known, so a resumed file does not + // start at 0 in the progress UI + opts.callback->on_start(p); + } + LOG_DBG("%s: downloading from %s to %s (etag:%s)...\n", __func__, common_http_show_masked_url(parts).c_str(), path_temporary.c_str(), etag.c_str()); @@ -393,12 +395,7 @@ static int common_download_file_single_online(const std::string & url, if (opts.callback) { opts.callback->on_done(p, success); } - if (opts.callback && opts.callback->is_cancelled() && - std::filesystem::exists(path_temporary)) { - if (remove(path_temporary.c_str()) != 0) { - LOG_ERR("%s: unable to delete temporary file: %s\n", __func__, path_temporary.c_str()); - } - } + // a stopped download keeps path_temporary, so the next attempt resumes from it if (!success) { LOG_ERR("%s: download failed after %d attempts\n", __func__, max_attempts); return -1; // max attempts reached diff --git a/tools/ui/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsDownloadOptions/ModelsDiscoverDetailsDownloadOptionsQuantDownloadButton.svelte b/tools/ui/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsDownloadOptions/ModelsDiscoverDetailsDownloadOptionsQuantDownloadButton.svelte index 4755ca42e9..fdc48f00a2 100644 --- a/tools/ui/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsDownloadOptions/ModelsDiscoverDetailsDownloadOptionsQuantDownloadButton.svelte +++ b/tools/ui/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsDownloadOptions/ModelsDiscoverDetailsDownloadOptionsQuantDownloadButton.svelte @@ -219,8 +219,8 @@ {@render tooltipTrigger(tooltipText, deleteChip)} {:else if entry.isDownloading || entry.isPaused} + inside the chip cancels the download. The X slot is reserved, so the chip + never reflows when the affordance fades in -->