]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Touch up secondary storage code slightly
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 10 Jul 2021 11:55:38 +0000 (13:55 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 10 Jul 2021 12:06:21 +0000 (14:06 +0200)
doc/MANUAL.adoc
src/storage/secondary/FileStorage.cpp
src/storage/secondary/FileStorage.hpp
src/storage/secondary/HttpStorage.cpp
src/storage/secondary/HttpStorage.hpp

index fe5f7cdb723d1cca0e7cd82ba663a19abb04f29b..f7386d3e3626fe73fb29f099996cbdd65e83dc3a 100644 (file)
@@ -936,8 +936,8 @@ Optional attributes:
 
 URL format: `http://HOST[:PORT][/PATH]`
 
-This backend stores data in an HTTP compatible server. The required HTTP
-methods are `GET`, `PUT` and `DELETE`.
+This backend stores data in an HTTP-compatible server. The required HTTP methods
+are `GET`, `PUT` and `DELETE`.
 
 Note that ccache will not perform any cleanup of the HTTP storage.
 
@@ -948,10 +948,10 @@ Examples:
 
 Known issues and limitations:
 
-* URLs containing IPv6 addresses like `http://[::1]/` are not supported
-* There are no HTTP timeouts implemented or configured
-* Authentication is not yet supported
-* HTTPS is not yet supported
+* There are no HTTP timeouts implemented or configured.
+* Authentication is not yet supported.
+* HTTPS is not yet supported.
+* URLs containing IPv6 addresses like `http://[::1]/` are not supported.
 
 == Cache size management
 
index 3c0e5985bff440e46a1e1c95c061b395bf7f0e8e..ab6b2fd73ef3a2b66252925563bb882e87076f3f 100644 (file)
@@ -105,7 +105,7 @@ FileStorage::get(const Digest& key)
 nonstd::expected<bool, SecondaryStorage::Error>
 FileStorage::put(const Digest& key,
                  const std::string& value,
-                 bool only_if_missing)
+                 const bool only_if_missing)
 {
   const auto path = get_entry_path(key);
 
index ac4271a84ec75dba64669d6a59ca9e07de44f468..0703e1be385a7ac10eea22ae46c9fef34a3518f2 100644 (file)
@@ -28,7 +28,7 @@
 namespace storage {
 namespace secondary {
 
-class FileStorage : public storage::SecondaryStorage
+class FileStorage : public SecondaryStorage
 {
 public:
   FileStorage(const Url& url, const AttributeMap& attributes);
index 5c4bd21ab141f8081f6f2dced93a21af436d8a3e..7ec99c3480c0e56a76d6417db23582bd66ac725d 100644 (file)
@@ -35,7 +35,7 @@ namespace secondary {
 namespace {
 
 nonstd::string_view
-to_string(httplib::Error error)
+to_string(const httplib::Error error)
 {
   using httplib::Error;
 
@@ -76,8 +76,7 @@ get_url_port(const Url& url)
 {
   if (!url.port().empty()) {
     return Util::parse_unsigned(url.port(), 1, 65535, "port");
-  }
-  if (url.scheme() == "http") {
+  } else if (url.scheme() == "http") {
     return 80;
   } else {
     throw Error("Unknown scheme: {}", url.scheme());
@@ -112,7 +111,6 @@ nonstd::expected<nonstd::optional<std::string>, SecondaryStorage::Error>
 HttpStorage::get(const Digest& key)
 {
   const auto url_path = get_entry_path(key);
-
   const auto result = m_http_client->Get(url_path.c_str());
 
   if (result.error() != httplib::Error::Success || !result) {
@@ -134,7 +132,7 @@ HttpStorage::get(const Digest& key)
 nonstd::expected<bool, SecondaryStorage::Error>
 HttpStorage::put(const Digest& key,
                  const std::string& value,
-                 bool only_if_missing)
+                 const bool only_if_missing)
 {
   const auto url_path = get_entry_path(key);
 
@@ -157,8 +155,7 @@ HttpStorage::put(const Digest& key,
     }
   }
 
-  const auto content_type = "application/octet-stream";
-
+  static const auto content_type = "application/octet-stream";
   const auto result = m_http_client->Put(
     url_path.c_str(), value.data(), value.size(), content_type);
 
@@ -184,7 +181,6 @@ nonstd::expected<bool, SecondaryStorage::Error>
 HttpStorage::remove(const Digest& key)
 {
   const auto url_path = get_entry_path(key);
-
   const auto result = m_http_client->Delete(url_path.c_str());
 
   if (result.error() != httplib::Error::Success || !result) {
index e0ea61b8f478509497857b671e4844a4256d1309..f9d46ba23174fd8dce2ed218c2a4b8364c1101c0 100644 (file)
@@ -25,6 +25,7 @@
 #include <string>
 
 class Url;
+
 namespace httplib {
 class Client;
 }
@@ -32,7 +33,7 @@ class Client;
 namespace storage {
 namespace secondary {
 
-class HttpStorage : public storage::SecondaryStorage
+class HttpStorage : public SecondaryStorage
 {
 public:
   HttpStorage(const Url& url, const AttributeMap& attributes);