diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-04-02 16:34:22 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-04-17 09:28:54 +0200 |
commit | 8d9b157cc4b6f1dec51de3696f4e96b853c22aa1 (patch) | |
tree | 43b5edf6e821647546a4e9e3422633c237e90be1 /src | |
parent | 4dc2cafb17c2dbdb58ada3a200e843a894bfc113 (diff) | |
download | justbuild-8d9b157cc4b6f1dec51de3696f4e96b853c22aa1.tar.gz |
Compactification: Obtain storage roots from LocalCAS.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/file_system/file_storage.hpp | 3 | ||||
-rw-r--r-- | src/buildtool/file_system/object_cas.hpp | 6 | ||||
-rw-r--r-- | src/buildtool/storage/large_object_cas.hpp | 6 | ||||
-rw-r--r-- | src/buildtool/storage/local_cas.hpp | 20 |
4 files changed, 34 insertions, 1 deletions
diff --git a/src/buildtool/file_system/file_storage.hpp b/src/buildtool/file_system/file_storage.hpp index 6006a410..178fa7da 100644 --- a/src/buildtool/file_system/file_storage.hpp +++ b/src/buildtool/file_system/file_storage.hpp @@ -74,7 +74,8 @@ class FileStorage { return storage_root_ / id.substr(0, 2) / id.substr(2, id.size() - 2); } - [[nodiscard]] auto StorageRoot() const noexcept -> std::filesystem::path { + [[nodiscard]] auto StorageRoot() const noexcept + -> std::filesystem::path const& { return storage_root_; } diff --git a/src/buildtool/file_system/object_cas.hpp b/src/buildtool/file_system/object_cas.hpp index 6dd1ae9f..185dc26a 100644 --- a/src/buildtool/file_system/object_cas.hpp +++ b/src/buildtool/file_system/object_cas.hpp @@ -65,6 +65,12 @@ class ObjectCAS { auto operator=(ObjectCAS&&) -> ObjectCAS& = delete; ~ObjectCAS() noexcept = default; + /// \brief Obtain path to the storage root. + [[nodiscard]] auto StorageRoot() const noexcept + -> std::filesystem::path const& { + return file_store_.StorageRoot(); + } + /// \brief Store blob from bytes. /// \param bytes The bytes do create the blob from. /// \returns Digest of the stored blob or nullopt in case of error. diff --git a/src/buildtool/storage/large_object_cas.hpp b/src/buildtool/storage/large_object_cas.hpp index e3fbf6cb..cb81d8b5 100644 --- a/src/buildtool/storage/large_object_cas.hpp +++ b/src/buildtool/storage/large_object_cas.hpp @@ -106,6 +106,12 @@ class LargeObjectCAS final { auto operator=(LargeObjectCAS&&) -> LargeObjectCAS& = delete; ~LargeObjectCAS() noexcept = default; + /// \brief Obtain path to the storage root. + [[nodiscard]] auto StorageRoot() const noexcept + -> std::filesystem::path const& { + return file_store_.StorageRoot(); + } + /// \brief Get the path to a large entry in the storage. /// \param digest The digest of a large object. /// \returns Path to the large entry if in the storage. diff --git a/src/buildtool/storage/local_cas.hpp b/src/buildtool/storage/local_cas.hpp index 449878a2..451e749c 100644 --- a/src/buildtool/storage/local_cas.hpp +++ b/src/buildtool/storage/local_cas.hpp @@ -54,6 +54,26 @@ class LocalCAS { base.string() + "-large-" + (Compatibility::IsCompatible() ? 'f' : 't')} {} + /// \brief Obtain path to the storage root. + /// \param type Type of the storage to be obtained. + /// \param large True if a large storage is needed. + [[nodiscard]] auto StorageRoot(ObjectType type, + bool large = false) const noexcept + -> std::filesystem::path const& { + if (large) { + return IsTreeObject(type) ? cas_tree_large_.StorageRoot() + : cas_file_large_.StorageRoot(); + } + switch (type) { + case ObjectType::Tree: + return cas_tree_.StorageRoot(); + case ObjectType::Executable: + return cas_exec_.StorageRoot(); + default: + return cas_file_.StorageRoot(); + } + } + /// \brief Store blob from file path with x-bit. /// \tparam kOwner Indicates ownership for optimization (hardlink). /// \param file_path The path of the file to store as blob. |