Directory: | cvmfs/ |
---|---|
File: | cvmfs/catalog_mgr_ro.h |
Date: | 2025-02-09 02:34:19 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 6 | 6 | 100.0% |
Branches: | 6 | 11 | 54.5% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /** | ||
2 | * This file is part of the CernVM File System. | ||
3 | * | ||
4 | * The SimpleCatalogManager is a simplistic concrete implementation of the | ||
5 | * AbstractCatalogManager and allows for easy-to-use access to the catalog | ||
6 | * structure of a given repository. This class is tailored for simplicity, not | ||
7 | * for performance. Have a look into ClientCatalogManager if you are working | ||
8 | * on the CVMFS client. | ||
9 | */ | ||
10 | |||
11 | #ifndef CVMFS_CATALOG_MGR_RO_H_ | ||
12 | #define CVMFS_CATALOG_MGR_RO_H_ | ||
13 | |||
14 | #include <string> | ||
15 | |||
16 | #include "catalog_mgr.h" | ||
17 | |||
18 | namespace download { | ||
19 | class DownloadManager; | ||
20 | } | ||
21 | |||
22 | namespace manifest { | ||
23 | class Manifest; | ||
24 | } | ||
25 | |||
26 | namespace perf { | ||
27 | class Statistics; | ||
28 | } | ||
29 | |||
30 | namespace catalog { | ||
31 | |||
32 | class SimpleCatalogManager : public AbstractCatalogManager<Catalog> { | ||
33 | public: | ||
34 | SimpleCatalogManager( | ||
35 | const shash::Any &base_hash, | ||
36 | const std::string &stratum0, | ||
37 | const std::string &dir_temp, | ||
38 | download::DownloadManager *download_manager, | ||
39 | perf::Statistics *statistics, | ||
40 | const bool manage_catalog_files = false, | ||
41 | const std::string &dir_cache = "", | ||
42 | const bool copy_to_tmp_dir = false); | ||
43 | |||
44 | protected: | ||
45 | virtual LoadReturn GetNewRootCatalogContext(CatalogContext *result); | ||
46 | virtual LoadReturn LoadCatalogByHash(CatalogContext *ctlg_context); | ||
47 | virtual Catalog* CreateCatalog(const PathString &mountpoint, | ||
48 | const shash::Any &catalog_hash, | ||
49 | Catalog *parent_catalog); | ||
50 | |||
51 | 40 | const shash::Any& base_hash() const { return base_hash_; } | |
52 | 20 | void set_base_hash(const shash::Any &hash) { base_hash_ = hash; } | |
53 | 29 | const std::string& dir_temp() const { return dir_temp_; } | |
54 | |||
55 | /** | ||
56 | * Makes the given path relative to the catalog structure | ||
57 | * Paths coming out here can be used for lookups in catalogs | ||
58 | * @param relativePath the path to be mangled | ||
59 | * @return the mangled path | ||
60 | */ | ||
61 | 321 | inline std::string MakeRelativePath(const std::string &relative_path) const { | |
62 |
6/11✓ Branch 1 taken 37 times.
✓ Branch 2 taken 284 times.
✓ Branch 5 taken 37 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 284 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 37 times.
✓ Branch 11 taken 284 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
321 | return (relative_path == "") ? "" : "/" + relative_path; |
63 | } | ||
64 | |||
65 | 147 | bool UseLocalCache() const { return !dir_cache_.empty(); } | |
66 | |||
67 | std::string dir_cache_; // absolute path to local cache | ||
68 | // directory | ||
69 | bool copy_to_tmp_dir_; // only relevant if using local | ||
70 | // cache directory: | ||
71 | // for writeable catalogs a copy | ||
72 | // must be created in dir_temp_ | ||
73 | |||
74 | private: | ||
75 | std::string CopyCatalogToTempFile(const std::string &cache_path); | ||
76 | |||
77 | shash::Any base_hash_; | ||
78 | std::string stratum0_; | ||
79 | std::string dir_temp_; | ||
80 | download::DownloadManager *download_manager_; | ||
81 | const bool manage_catalog_files_; | ||
82 | }; // class SimpleCatalogManager | ||
83 | |||
84 | } // namespace catalog | ||
85 | |||
86 | #endif // CVMFS_CATALOG_MGR_RO_H_ | ||
87 |