Loading tools/releasetools/blockimgdiff.py +10 −13 Original line number Diff line number Diff line Loading @@ -776,8 +776,6 @@ class BlockImageDiff(object): src_ranges = xf.src_ranges tgt_ranges = xf.tgt_ranges # Needs lock since WriteRangeDataToFd() is stateful (calling seek). with lock: src_file = common.MakeTempFile(prefix="src-") with open(src_file, "wb") as fd: self.src.WriteRangeDataToFd(src_ranges, fd) Loading Loading @@ -1430,7 +1428,6 @@ class BlockImageDiff(object): src_file = common.MakeTempFile(prefix="src-") tgt_file = common.MakeTempFile(prefix="tgt-") with transfer_lock: with open(src_file, "wb") as src_fd: self.src.WriteRangeDataToFd(src_ranges, src_fd) with open(tgt_file, "wb") as tgt_fd: Loading tools/releasetools/sparse_img.py +26 −23 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import bisect import os import struct import threading from hashlib import sha1 import rangelib Loading Loading @@ -111,6 +112,8 @@ class SparseImage(object): raise ValueError("Unknown chunk type 0x%04X not supported" % (chunk_type,)) self.generator_lock = threading.Lock() self.care_map = rangelib.RangeSet(care_data) self.offset_index = [i[0] for i in offset_map] Loading Loading @@ -173,11 +176,11 @@ class SparseImage(object): particular is not necessarily equal to the number of ranges in 'ranges'. This generator is stateful -- it depends on the open file object contained in this SparseImage, so you should not try to run two Use a lock to protect the generator so that we will not run two instances of this generator on the same object simultaneously.""" f = self.simg_f with self.generator_lock: for s, e in ranges: to_read = e-s idx = bisect.bisect_right(self.offset_index, s) - 1 Loading Loading
tools/releasetools/blockimgdiff.py +10 −13 Original line number Diff line number Diff line Loading @@ -776,8 +776,6 @@ class BlockImageDiff(object): src_ranges = xf.src_ranges tgt_ranges = xf.tgt_ranges # Needs lock since WriteRangeDataToFd() is stateful (calling seek). with lock: src_file = common.MakeTempFile(prefix="src-") with open(src_file, "wb") as fd: self.src.WriteRangeDataToFd(src_ranges, fd) Loading Loading @@ -1430,7 +1428,6 @@ class BlockImageDiff(object): src_file = common.MakeTempFile(prefix="src-") tgt_file = common.MakeTempFile(prefix="tgt-") with transfer_lock: with open(src_file, "wb") as src_fd: self.src.WriteRangeDataToFd(src_ranges, src_fd) with open(tgt_file, "wb") as tgt_fd: Loading
tools/releasetools/sparse_img.py +26 −23 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import bisect import os import struct import threading from hashlib import sha1 import rangelib Loading Loading @@ -111,6 +112,8 @@ class SparseImage(object): raise ValueError("Unknown chunk type 0x%04X not supported" % (chunk_type,)) self.generator_lock = threading.Lock() self.care_map = rangelib.RangeSet(care_data) self.offset_index = [i[0] for i in offset_map] Loading Loading @@ -173,11 +176,11 @@ class SparseImage(object): particular is not necessarily equal to the number of ranges in 'ranges'. This generator is stateful -- it depends on the open file object contained in this SparseImage, so you should not try to run two Use a lock to protect the generator so that we will not run two instances of this generator on the same object simultaneously.""" f = self.simg_f with self.generator_lock: for s, e in ranges: to_read = e-s idx = bisect.bisect_right(self.offset_index, s) - 1 Loading