Loading editor/src/webedit_api.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -5544,6 +5544,13 @@ void webedit::Api::handleImportHtml(libhttppp::HttpRequest &curreq, const size_t kMaxImages = 150; const size_t kMaxImageBytes = 15 * 1024 * 1024; std::unordered_map<std::string, UploadedExternalImage> uploaded; // Many CDNs serve every image off an opaque/generic path (or none // at all -- e.g. a query-string-only cache key), so the filename // derived below collides constantly across a real page's images. // Without disambiguation, every collision after the first // silently overwrites the previous upload in mediadb under the // same name. Counts across the whole job, not just per batch. std::unordered_map<std::string, int> filenameCounts; int imported = 0, failed = 0; size_t importCount = std::min(externalUrls.size(), kMaxImages); Loading @@ -5560,6 +5567,11 @@ void webedit::Api::handleImportHtml(libhttppp::HttpRequest &curreq, std::string filename = std::filesystem::path(url).filename().string(); if (filename.empty()) filename = "image"; int seen = filenameCounts[filename]++; if (seen > 0) { std::filesystem::path p(filename); filename = p.stem().string() + "-" + std::to_string(seen + 1) + p.extension().string(); } std::string b64 = encodeBase64(bytes); json_object *arr = json_object_new_array(); Loading Loading
editor/src/webedit_api.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -5544,6 +5544,13 @@ void webedit::Api::handleImportHtml(libhttppp::HttpRequest &curreq, const size_t kMaxImages = 150; const size_t kMaxImageBytes = 15 * 1024 * 1024; std::unordered_map<std::string, UploadedExternalImage> uploaded; // Many CDNs serve every image off an opaque/generic path (or none // at all -- e.g. a query-string-only cache key), so the filename // derived below collides constantly across a real page's images. // Without disambiguation, every collision after the first // silently overwrites the previous upload in mediadb under the // same name. Counts across the whole job, not just per batch. std::unordered_map<std::string, int> filenameCounts; int imported = 0, failed = 0; size_t importCount = std::min(externalUrls.size(), kMaxImages); Loading @@ -5560,6 +5567,11 @@ void webedit::Api::handleImportHtml(libhttppp::HttpRequest &curreq, std::string filename = std::filesystem::path(url).filename().string(); if (filename.empty()) filename = "image"; int seen = filenameCounts[filename]++; if (seen > 0) { std::filesystem::path p(filename); filename = p.stem().string() + "-" + std::to_string(seen + 1) + p.extension().string(); } std::string b64 = encodeBase64(bytes); json_object *arr = json_object_new_array(); Loading