Skip to contentSkip to conversation

bb.cache: prevent division-by-zero in load_cahefile()

PATCH New Markus Lehtonen 1 participant 1 message Apr 10, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bb.cache: prevent division-by-zero in load_cahefile()

[YOCTO 11315]

---
 lib/bb/cache.py | 4 ++++
 1 file changed, 4 insertions(+)
lib/bb/cache.py +4 -0
index 28e8a874..e7eeb4f5 100644
@@ -462,6 +462,10 @@ class Cache(NoCache):
                         self.depends_cache[key] = [value]
                     # only fire events on even percentage boundaries
                     current_progress = cachefile.tell() + previous_progress
+                    if current_progress > cachesize:
+                        # we might have calculated incorrect total size because a file
+                        # might've been written out just after we checked its size
+                        cachesize = current_progress
                     current_percent = 100 * current_progress / cachesize
                     if current_percent > previous_percent:
                         previous_percent = current_percent
Signature · 1 line
2.12.0