GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/catalog_mgr_ro.h
Date: 2025-06-22 02:36:02
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(const shash::Any &base_hash,
35 const std::string &stratum0,
36 const std::string &dir_temp,
37 download::DownloadManager *download_manager,
38 perf::Statistics *statistics,
39 const bool manage_catalog_files = false,
40 const std::string &dir_cache = "",
41 const bool copy_to_tmp_dir = false);
42
43 virtual LoadReturn LoadCatalogByHash(CatalogContext *ctlg_context);
44 protected:
45 virtual LoadReturn GetNewRootCatalogContext(CatalogContext *result);
46 virtual Catalog *CreateCatalog(const PathString &mountpoint,
47 const shash::Any &catalog_hash,
48 Catalog *parent_catalog);
49
50 1726 const shash::Any &base_hash() const { return base_hash_; }
51 863 void set_base_hash(const shash::Any &hash) { base_hash_ = hash; }
52 981 const std::string &dir_temp() const { return dir_temp_; }
53
54 /**
55 * Makes the given path relative to the catalog structure
56 * Paths coming out here can be used for lookups in catalogs
57 * @param relativePath the path to be mangled
58 * @return the mangled path
59 */
60 11568 inline std::string MakeRelativePath(const std::string &relative_path) const {
61
6/11
✓ Branch 1 taken 1544 times.
✓ Branch 2 taken 10024 times.
✓ Branch 5 taken 1544 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 10024 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1544 times.
✓ Branch 11 taken 10024 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
11568 return (relative_path == "") ? "" : "/" + relative_path;
62 }
63
64 5555 bool UseLocalCache() const { return !dir_cache_.empty(); }
65
66 std::string dir_cache_; // absolute path to local cache
67 // directory
68 bool copy_to_tmp_dir_; // only relevant if using local
69 // cache directory:
70 // for writeable catalogs a copy
71 // must be created in dir_temp_
72
73 private:
74 std::string CopyCatalogToTempFile(const std::string &cache_path);
75
76 shash::Any base_hash_;
77 std::string stratum0_;
78 std::string dir_temp_;
79 download::DownloadManager *download_manager_;
80 const bool manage_catalog_files_;
81 }; // class SimpleCatalogManager
82
83 } // namespace catalog
84
85 #endif // CVMFS_CATALOG_MGR_RO_H_
86