From 8593dd5f8e0e7ce4574ca1833f759a41b1a8546c Mon Sep 17 00:00:00 2001 From: Jorge Camarero Vera <jorge.camarero@cern.ch> Date: Tue, 2 Aug 2022 16:46:49 +0200 Subject: [PATCH] Resolve "Do NOT allow capacity change of a cartridge if there a still files registered on that tape" --- cmdline/CtaAdminCmdParse.hpp | 2 +- xroot_plugins/XrdSsiCtaRequestMessage.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmdline/CtaAdminCmdParse.hpp b/cmdline/CtaAdminCmdParse.hpp index 293387a5d2..fad0132734 100644 --- a/cmdline/CtaAdminCmdParse.hpp +++ b/cmdline/CtaAdminCmdParse.hpp @@ -600,7 +600,7 @@ const std::map<cmd_key_t, cmd_val_t> cmdOptions = { {{ AdminCmd::CMD_MEDIATYPE, AdminCmd::SUBCMD_ADD }, { opt_mediatype_alias, opt_cartridge, opt_capacity, opt_primarydensitycode.optional(), opt_secondarydensitycode.optional(), opt_number_of_wraps.optional(), opt_minlpos.optional(), opt_maxlpos.optional(), opt_comment }}, {{ AdminCmd::CMD_MEDIATYPE, AdminCmd::SUBCMD_CH }, - { opt_mediatype_alias, opt_cartridge.optional(), opt_capacity.optional(), opt_primarydensitycode.optional(), opt_secondarydensitycode.optional(), opt_number_of_wraps.optional(), opt_minlpos.optional(), opt_maxlpos.optional(),opt_comment.optional() }}, + { opt_mediatype_alias, opt_cartridge.optional(), opt_primarydensitycode.optional(), opt_secondarydensitycode.optional(), opt_number_of_wraps.optional(), opt_minlpos.optional(), opt_maxlpos.optional(),opt_comment.optional() }}, {{ AdminCmd::CMD_MEDIATYPE, AdminCmd::SUBCMD_RM }, { opt_mediatype_alias }}, {{ AdminCmd::CMD_MEDIATYPE, AdminCmd::SUBCMD_LS }, { }}, /*----------------------------------------------------------------------------------------------------*/ diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.cpp b/xroot_plugins/XrdSsiCtaRequestMessage.cpp index 66e53e9a08..ffe2d0e452 100644 --- a/xroot_plugins/XrdSsiCtaRequestMessage.cpp +++ b/xroot_plugins/XrdSsiCtaRequestMessage.cpp @@ -1389,7 +1389,6 @@ void RequestMessage::processMediaType_Ch(cta::xrd::Response &response) auto &mediaTypeName = getRequired(OptionString::MEDIA_TYPE); auto cartridge = getOptional(OptionString::CARTRIDGE); - auto capacityInBytes = getOptional(OptionUInt64::CAPACITY); auto primaryDensityCode = getOptional(OptionUInt64::PRIMARY_DENSITY_CODE); auto secondaryDensityCode = getOptional(OptionUInt64::SECONDARY_DENSITY_CODE); auto nbWraps = getOptional(OptionUInt64::NUMBER_OF_WRAPS); @@ -1420,9 +1419,6 @@ void RequestMessage::processMediaType_Ch(cta::xrd::Response &response) if(cartridge){ m_catalogue.modifyMediaTypeCartridge(m_cliIdentity,mediaTypeName,cartridge.value()); } - if(capacityInBytes){ - m_catalogue.modifyMediaTypeCapacityInBytes(m_cliIdentity,mediaTypeName,capacityInBytes.value()); - } if(primaryDensityCode){ m_catalogue.modifyMediaTypePrimaryDensityCode(m_cliIdentity,mediaTypeName,primaryDensityCode.value()); } @@ -1945,6 +1941,10 @@ void RequestMessage::processTape_Ch(cta::xrd::Response &response) auto verificationStatus = getOptional(OptionString::VERIFICATION_STATUS); if(mediaType) { + if (m_catalogue.getNbFilesOnTape(vid) != 0) { + response.set_type(cta::xrd::Response::RSP_ERR_CTA); + return; + } m_catalogue.modifyTapeMediaType(m_cliIdentity, vid, mediaType.value()); } if(vendor) { -- GitLab