summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tao Bao <tbao@google.com> 2016-11-05 00:09:35 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-11-05 00:09:35 +0000
commit49758959f204f408f3391e9c1541e8f3e61a0b6f (patch)
treefe90c6b7589ee9707434c40c5d37e1d76ee9d461
parentb9bd78d1109dd2a0b8b0da4492914b937e8a4e00 (diff)
parentccc5c40523e35e9ddc4379c68024479dec9bafc5 (diff)
Merge "releasetools: compare size between compressed and patch while build otapackage"
-rw-r--r--tools/releasetools/common.py3
-rwxr-xr-xtools/releasetools/ota_from_target_files.py4
2 files changed, 4 insertions, 3 deletions
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index fad6a5ec28..5f81d53ef3 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -1203,10 +1203,11 @@ class DeviceSpecificParams(object):
return self._DoCall("VerifyOTA_Assertions")
class File(object):
- def __init__(self, name, data):
+ def __init__(self, name, data, compress_size = None):
self.name = name
self.data = data
self.size = len(data)
+ self.compress_size = compress_size or self.size
self.sha1 = sha1(data).hexdigest()
@classmethod
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index f32d9d8213..403a3a4600 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -748,7 +748,7 @@ def LoadPartitionFiles(z, partition):
basefilename = info.filename[len(prefix):]
fn = partition + "/" + basefilename
data = z.read(info.filename)
- out[fn] = common.File(fn, data)
+ out[fn] = common.File(fn, data, info.compress_size)
return out
@@ -1379,7 +1379,7 @@ class FileDifference(object):
for diff in diffs:
tf, sf, d = diff.GetPatch()
path = "/".join(tf.name.split("/")[:-1])
- if d is None or len(d) > tf.size * OPTIONS.patch_threshold or \
+ if d is None or len(d) > tf.compress_size * OPTIONS.patch_threshold or \
path not in known_paths:
# patch is almost as big as the file; don't bother patching
# or a patch + rename cannot take place due to the target