diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp index f91fce351ee017dd67e32df28e5a64c52fbf3aa0..3bdf329f8569dfd899cecabde44642d68c5dbd1f 100644 --- a/scheduler/Scheduler.cpp +++ b/scheduler/Scheduler.cpp @@ -413,6 +413,18 @@ common::dataStructures::RepackInfo Scheduler::getRepack(const std::string &vid) return m_db.getRepackInfo(vid); } +//------------------------------------------------------------------------------ +// isBeingRepacked +//------------------------------------------------------------------------------ +bool Scheduler::isBeingRepacked(const std::string &vid) { + try { + getRepack(vid); + return true; + } catch(cta::exception::UserError) { + return false; + } +} + //------------------------------------------------------------------------------ // promoteRepackRequestsToToExpand //------------------------------------------------------------------------------ diff --git a/scheduler/Scheduler.hpp b/scheduler/Scheduler.hpp index ebf78e1b188c112ac61879dc053ed5cf114f2893..8e0094721af9de74323b567ba0f234b388c9c807 100644 --- a/scheduler/Scheduler.hpp +++ b/scheduler/Scheduler.hpp @@ -208,6 +208,7 @@ public: void cancelRepack(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, log::LogContext & lc); std::list<cta::common::dataStructures::RepackInfo> getRepacks(); cta::common::dataStructures::RepackInfo getRepack(const std::string &vid); + bool isBeingRepacked(const std::string &vid); std::map<std::string, std::list<cta::common::dataStructures::ArchiveJob> > getPendingArchiveJobs(log::LogContext &lc) const; std::list<cta::common::dataStructures::ArchiveJob> getPendingArchiveJobs(const std::string &tapePoolName, log::LogContext &lc) const; diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.cpp b/xroot_plugins/XrdSsiCtaRequestMessage.cpp index 4d4176c8cc313f70b1d127611fbff2a65196e482..0ae6dafac90cf4b9034e1f213d8e52a9b2449449 100644 --- a/xroot_plugins/XrdSsiCtaRequestMessage.cpp +++ b/xroot_plugins/XrdSsiCtaRequestMessage.cpp @@ -1763,6 +1763,9 @@ void RequestMessage::processTape_Rm(cta::xrd::Response &response) auto &vid = getRequired(OptionString::VID); + if (m_scheduler.isBeingRepacked(vid)) { + throw cta::exception::UserError("Cannot delete tape " + vid + " because there is a repack for that tape"); + } m_catalogue.deleteTape(vid); response.set_type(cta::xrd::Response::RSP_SUCCESS);