- (checksum, size, blockid))
- else:
- self.cursor.execute(
- """insert into block_index(
- segmentid, object, checksum, size, timestamp)
- values (?, ?, ?, ?, julianday('now'))""",
- (segmentid, object, checksum, size))
- blockid = self.cursor.lastrowid
+ (checksum, blockid))
+
+ # Update the object size. Our size may be an estimate, based on
+ # slices that we have seen. The size in the database must not be
+ # larger than the true size, but update it to the largest value
+ # possible.
+ self.cursor.execute("""update block_index
+ set size = max(?, coalesce(size, 0))
+ where blockid = ?""",
+ (size, blockid))