10#include <framework/database/PayloadMetadata.h>
11#include <framework/database/Downloader.h>
12#include <framework/utilities/FileSystem.h>
16#include <unordered_map>
18namespace Belle2::Conditions {
64 explicit PayloadProvider(
const std::vector<std::string>& locations,
const std::string& cachedir =
"",
int timeout = 60);
97 std::unordered_map<std::string, std::unique_ptr<FileSystem::TemporaryFile>>
m_temporaryFiles;
Simple class to encapsulate libcurl as used by the ConditionsDatabase.
static Downloader & getDefaultInstance()
Return the default instance.
Class to find payload files in a list of locations.
bool getTemporaryFile(const std::string &url, PayloadMetadata &meta, bool silentOnMissing)
Try to download url into a temporary file, if successful set the filename member of the metadata and ...
PayloadLocation m_cacheDir
Location of the cache directory where/how we want to store downloaded payloads.
bool getLocalFile(const PayloadLocation &loc, PayloadMetadata &meta) const
Look for a payload in the local directory location, set the filename member of the metadata instance ...
std::vector< PayloadLocation > m_locations
List of configured lookup locations: The first one will always be the cache directory and the last on...
std::unordered_map< std::string, std::unique_ptr< FileSystem::TemporaryFile > > m_temporaryFiles
Map of all active temporary files we downloaded and keep around until they can be closed.
int m_timeout
Timeout to wait for a write look when trying to download payloads.
EDirectoryLayout
Enumeration of different directory layouts.
@ c_flat
Flat directory containing the payloads in the form dbstore_{NAME}_rev_{REVISION}.root
@ c_hashed
Hashed directory structure containing the payloads in the form AB/{NAME}_r{REVISION}....
std::string getFilename(EDirectoryLayout structure, const PayloadMetadata &payload) const
Return the filename of a payload to look for given a directory structure and some metadata.
Downloader & m_downloader
Instance to the database file downloading instance.
bool find(PayloadMetadata &meta)
Try to find a payload, return true on success, false if it cannot be found.
bool getRemoteFile(const PayloadLocation &loc, PayloadMetadata &meta)
Look for a payload on a remote server and download if possible, set the filename member of the metada...
Simple struct to represent a lookup location.
bool isRemote
Is this a remote location where we want to download the files?
std::string base
base path or uri