| 353 | } |
| 354 | |
| 355 | void DataStorageController::ReleaseRequestTempDir(const std::string& clientIp, const fs::path& dir) |
| 356 | { |
| 357 | // Delete from disk first; deregistration is cheap even if deletion fails. |
| 358 | fs::remove_all(dir); |
| 359 | |
| 360 | std::lock_guard<std::mutex> lock(m_ActiveTempDirsMutex); |
| 361 | |
| 362 | auto mapIt = m_ActiveTempDirsByIp.find(clientIp); |
| 363 | if (mapIt == m_ActiveTempDirsByIp.end()) |
| 364 | return; |
| 365 | |
| 366 | auto& queue = mapIt->second; |
| 367 | const auto it = std::find(queue.begin(), queue.end(), dir); |
| 368 | if (it != queue.end()) |
| 369 | queue.erase(it); |
| 370 | |
| 371 | // Remove empty map entries to prevent the map growing unboundedly. |
| 372 | if (queue.empty()) |
| 373 | m_ActiveTempDirsByIp.erase(mapIt); |
| 374 | } |
| 375 | |
| 376 | std::string DataStorageController::DetermineTransferMode(const httplib::Request& req) const |
| 377 | { |