Add cleanup of stale temporary files before download

Remove stale temporary files before downloading.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Jean-Luc T.andCopilot Autofix powered by AI authored and GitHub committed 2026-10-13 13:41:07 +02:00
1 parent 80242c0ec8
commit 573aab4bdb
1 file changed
+1
+1
View File
@@ -197,6 +197,7 @@ std::optional<std::string> get_text(std::wstring_view url, std::uint64_t max_byt
const auto path = std::filesystem::path(length ? std::wstring(folder, length) : L".") /
(L"reskate-get-" + std::to_wstring(GetCurrentProcessId()) + L"-" + std::to_wstring(++serial) + L".tmp");
std::error_code error;
std::filesystem::remove(path, error); // discard a stale file left by an earlier process
const auto download = get(url, path, max_bytes, timeout_seconds, agent, watch);
if (result) *result = download;
std::optional<std::string> text;