Aktualizr
C++ SOTA Client
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
ostree_http_repo.h
1 #ifndef SOTA_CLIENT_TOOLS_OSTREE_HTTP_REPO_H_
2 #define SOTA_CLIENT_TOOLS_OSTREE_HTTP_REPO_H_
3 
4 #include <boost/filesystem.hpp>
5 
6 #include "logging/logging.h"
7 #include "ostree_ref.h"
8 #include "ostree_repo.h"
9 #include "treehub_server.h"
10 #include "utilities/utils.h"
11 
12 class OSTreeHttpRepo : public OSTreeRepo {
13  public:
14  explicit OSTreeHttpRepo(TreehubServer* server, const boost::filesystem::path& root_in = "")
15  : server_(server), root_(root_in) {
16  if (root_.empty()) {
17  root_ = root_tmp_.Path();
18  }
19  curlEasySetoptWrapper(easy_handle_.get(), CURLOPT_VERBOSE, get_curlopt_verbose());
20  curlEasySetoptWrapper(easy_handle_.get(), CURLOPT_WRITEFUNCTION, &OSTreeHttpRepo::curl_handle_write);
21  curlEasySetoptWrapper(easy_handle_.get(), CURLOPT_FAILONERROR, true);
22  }
23  ~OSTreeHttpRepo() override = default;
24 
25  bool LooksValid() const override;
26  OSTreeRef GetRef(const std::string& refname) const override;
27  boost::filesystem::path root() const override { return root_; }
28 
29  private:
30  bool FetchObject(const boost::filesystem::path& path) const override;
31  static size_t curl_handle_write(void* buffer, size_t size, size_t nmemb, void* userp);
32 
33  TreehubServer* server_;
34  boost::filesystem::path root_;
35  const TemporaryDirectory root_tmp_;
36  mutable CurlEasyWrapper easy_handle_;
37 };
38 
39 // vim: set tabstop=2 shiftwidth=2 expandtab:
40 #endif // SOTA_CLIENT_TOOLS_OSTREE_HTTP_REPO_H_
CurlEasyWrapper
Definition: utils.h:146
TreehubServer
Definition: treehub_server.h:11
TemporaryDirectory
Definition: utils.h:82
OSTreeRepo
A source repository to read OSTree objects from.
Definition: ostree_repo.h:19
OSTreeHttpRepo
Definition: ostree_http_repo.h:12
OSTreeRef
Definition: ostree_ref.h:13