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

Commit 35f015ea authored by Huang Jianan's avatar Huang Jianan Committed by jianan huang
Browse files

calculation partition size use compressed image size



If dynamic partitioning is enabled and the partition size is not set,
du will be used to calculate the partition size.

For compressed file systems, it's better to use the compressed size
to avoid wasting space.

Bug:174816929
Test: erofs image size is smaller than the original file
Change-Id: I1deda85d312c19620680531223fffcfb815e5fd4
Signed-off-by: default avatarHuang Jianan <huangjianan@oppo.com>
parent 62d926e2
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -427,6 +427,15 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None):
  if (prop_dict.get("use_dynamic_partition_size") == "true" and
      "partition_size" not in prop_dict):
    # If partition_size is not defined, use output of `du' + reserved_size.
    # For compressed file system, it's better to use the compressed size to avoid wasting space.
    if fs_type.startswith("erofs"):
      tmp_dict = prop_dict.copy()
      if "erofs_sparse_flag" in tmp_dict:
        tmp_dict.pop("erofs_sparse_flag")
      BuildImageMkfs(in_dir, tmp_dict, out_file, target_out, fs_config)
      size = GetDiskUsage(out_file)
      os.remove(out_file)
    else:
      size = GetDiskUsage(in_dir)
    logger.info(
        "The tree size of %s is %d MB.", in_dir, size // BYTES_IN_MB)