Skip to content
Snippets Groups Projects
Commit 5db5174d authored by Michael Davis's avatar Michael Davis
Browse files

[frontend] Adds showSuperseded to DB query for tapefile ls

parent e8d90ad3
Branches
Tags
No related merge requests found
......@@ -162,7 +162,7 @@ RdbmsCatalogueGetArchiveFilesItor::RdbmsCatalogueGetArchiveFilesItor(
}
if(hideSuperseded) {
if(addedAWhereConstraint) sql += " AND ";
sql += "TAPE_FILE.SUPERSEDED_BY_VID != ''";
sql += "TAPE_FILE.SUPERSEDED_BY_VID IS NULL";
addedAWhereConstraint = true;
}
......
......@@ -58,7 +58,6 @@ private:
catalogue::ArchiveFileItor m_tapeFileItor; //!< Iterator across files which have been archived
grpc::EndpointMap m_endpoints; //!< List of gRPC endpoints
bool m_LookupNamespace; //!< True if namespace lookup is required
bool m_ShowSuperseded; //!< True if superseded files should be included in the output
static constexpr const char* const LOG_SUFFIX = "TapeFileLsStream"; //!< Identifier for log messages
};
......@@ -75,14 +74,14 @@ TapeFileLsStream::TapeFileLsStream(const RequestMessage &requestMsg,
XrdSsiPb::Log::Msg(XrdSsiPb::Log::DEBUG, LOG_SUFFIX, "TapeFileLsStream() constructor");
m_LookupNamespace = true;
m_ShowSuperseded = requestMsg.has_flag(OptionBoolean::SHOW_SUPERSEDED);
bool has_any = false; // set to true if at least one optional option is set
// Get the search criteria from the optional options
cta::catalogue::TapeFileSearchCriteria searchCriteria;
searchCriteria.showSuperseded = requestMsg.has_flag(OptionBoolean::SHOW_SUPERSEDED);
searchCriteria.vid = requestMsg.getOptional(OptionString::VID, &has_any);
// Disk file IDs can be a list or a single ID
auto diskFileId = requestMsg.getOptional(OptionString::FXID, &has_any);
......@@ -98,6 +97,7 @@ TapeFileLsStream::TapeFileLsStream(const RequestMessage &requestMsg,
}
searchCriteria.diskFileIds->push_back(std::to_string(fid));
}
// Disk instance on its own does not give a valid set of search criteria (no &has_any)
searchCriteria.diskInstance = requestMsg.getOptional(OptionString::INSTANCE);
if(!has_any) {
......@@ -116,14 +116,6 @@ int TapeFileLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
for(auto jt = archiveFile.tapeFiles.cbegin(); jt != archiveFile.tapeFiles.cend(); jt++) {
Data record;
// Skip superseded files unless explicitly requested to show them
//
// Note: This could be implemented more efficiently by adding a showSuperseded flag to TapeFileSearchCriteria and
// filtering in the DB query in RdbmsCatalogueGetArchiveFilesItor. However, it is likely that the superseded
// files concept will be replaced by something else. Keeping the implementation here makes it easier to
// change the implementation.
if(!(m_ShowSuperseded || jt->supersededByVid.empty())) continue;
// Archive file
auto af = record.mutable_tfls_item()->mutable_af();
af->set_archive_id(archiveFile.archiveFileID);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment