| 1242 | } |
| 1243 | |
| 1244 | void RestServer::CleanupTempDirectory(const std::string& tempDir) |
| 1245 | { |
| 1246 | if (tempDir.empty()) |
| 1247 | { |
| 1248 | return; |
| 1249 | } |
| 1250 | |
| 1251 | try |
| 1252 | { |
| 1253 | fs::path tempPath(tempDir); |
| 1254 | if (fs::exists(tempPath)) |
| 1255 | { |
| 1256 | // Remove all contents recursively |
| 1257 | fs::remove_all(tempPath); |
| 1258 | MITK_DEBUG << "Cleaned up REST API temp directory: " << tempDir; |
| 1259 | } |
| 1260 | } |
| 1261 | catch (const std::exception& e) |
| 1262 | { |
| 1263 | MITK_WARN << "Failed to cleanup temp directory: " << e.what(); |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | } |