Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c74aecc8 authored by Dennis Shen's avatar Dennis Shen Committed by Automerger Merge Worker
Browse files

Merge "aconfig: add support for local override" into main am: e6b424ad

parents 0b27706b e6b424ad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ rust_protobuf {
    min_sdk_version: "29",
}

cc_library_static {
cc_library {
    name: "libaconfig_storage_protos_cc",
    proto: {
        export_proto_headers: true,
+2 −1
Original line number Diff line number Diff line
@@ -27,7 +27,8 @@ message storage_file_info {
  optional string flag_map = 4;
  optional string flag_val = 5;
  optional string flag_info = 6;
  optional int64 timestamp = 7;
  optional string local_overrides = 7;
  optional int64 timestamp = 8;
}

message storage_files {
+24 −23
Original line number Diff line number Diff line
@@ -66,8 +66,31 @@ static Result<std::string> find_storage_file(
  return Error() << "Unable to find storage files for container " << container;
}


namespace private_internal_api {

/// Get mutable mapped file implementation.
Result<MutableMappedStorageFile> get_mutable_mapped_file_impl(
    std::string const& pb_file,
    std::string const& container,
    StorageFileType file_type) {
  if (file_type != StorageFileType::flag_val &&
      file_type != StorageFileType::flag_info) {
    return Error() << "Cannot create mutable mapped file for this file type";
  }

  auto file_result = find_storage_file(pb_file, container, file_type);
  if (!file_result.ok()) {
    return Error() << file_result.error();
  }

  return map_mutable_storage_file(*file_result);
}

} // namespace private internal api

/// Map a storage file
static Result<MutableMappedStorageFile> map_storage_file(std::string const& file) {
Result<MutableMappedStorageFile> map_mutable_storage_file(std::string const& file) {
  struct stat file_stat;
  if (stat(file.c_str(), &file_stat) < 0) {
    return ErrnoError() << "stat failed";
@@ -97,28 +120,6 @@ static Result<MutableMappedStorageFile> map_storage_file(std::string const& file
  return mapped_file;
}

namespace private_internal_api {

/// Get mutable mapped file implementation.
Result<MutableMappedStorageFile> get_mutable_mapped_file_impl(
    std::string const& pb_file,
    std::string const& container,
    StorageFileType file_type) {
  if (file_type != StorageFileType::flag_val &&
      file_type != StorageFileType::flag_info) {
    return Error() << "Cannot create mutable mapped file for this file type";
  }

  auto file_result = find_storage_file(pb_file, container, file_type);
  if (!file_result.ok()) {
    return Error() << file_result.error();
  }

  return map_storage_file(*file_result);
}

} // namespace private internal api

/// Get mutable mapped file
Result<MutableMappedStorageFile> get_mutable_mapped_file(
    std::string const& container,
+4 −0
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@ Result<MutableMappedStorageFile> get_mutable_mapped_file_impl(

} // namespace private_internal_api

/// Map a storage file
Result<MutableMappedStorageFile> map_mutable_storage_file(
    std::string const& file);

/// Get mapped writeable storage file
Result<MutableMappedStorageFile> get_mutable_mapped_file(
    std::string const& container,