Mercurial > hg > orthanc
diff OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp @ 5364:b5f2122a1334
Added a route to delete completed jobs from history: DELETE /jobs/{id}
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 20 Jul 2023 10:51:34 +0200 |
parents | b5c502bcaf99 |
children | 48b8dae6dc77 |
line wrap: on
line diff
--- a/OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp Thu Jul 13 19:33:10 2023 +0200 +++ b/OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp Thu Jul 20 10:51:34 2023 +0200 @@ -649,6 +649,42 @@ } + bool JobsRegistry::DeleteJobInfo(const std::string& id) + { + LOG(INFO) << "Deleting job: " << id; + + boost::mutex::scoped_lock lock(mutex_); + CheckInvariants(); + + JobsIndex::iterator found = jobsIndex_.find(id); + + if (found == jobsIndex_.end()) + { + LOG(WARNING) << "Unknown job to delete: " << id; + return false; + } + else + { + for (CompletedJobs::iterator it = completedJobs_.begin(); + it != completedJobs_.end(); ++it) + { + if (*it == found->second) + { + found->second->GetJob().DeleteAllOutputs(); + delete found->second; + + completedJobs_.erase(it); + jobsIndex_.erase(id); + return true; + } + } + + LOG(WARNING) << "Can not delete a job that is not complete: " << id; + return false; + } + } + + bool JobsRegistry::GetJobOutput(std::string& output, MimeType& mime, std::string& filename,