Merge pull request #2852 from ThomasWaldmann/lgtm-fixes

lgtm fixes
This commit is contained in:
TW 2017-07-23 02:01:29 +02:00 committed by GitHub
commit 4fa8805407
4 changed files with 9 additions and 8 deletions

View File

@ -368,12 +368,12 @@ class build_usage(Command):
# "+ 1" because we want a space between the cell contents and the delimiting "|" in the output # "+ 1" because we want a space between the cell contents and the delimiting "|" in the output
column_widths[i] = max(column_widths[i], len(cells[i]) + 1) column_widths[i] = max(column_widths[i], len(cells[i]) + 1)
for columns, *cells in rows: for columns, *original_cells in rows:
write_row_separator() write_row_separator()
# If a cell contains newlines, then the row must be split up in individual rows # If a cell contains newlines, then the row must be split up in individual rows
# where each cell contains no newline. # where each cell contains no newline.
rowspanning_cells = [] rowspanning_cells = []
original_cells = list(cells) original_cells = list(original_cells)
while any('\n' in cell for cell in original_cells): while any('\n' in cell for cell in original_cells):
cell_bloc = [] cell_bloc = []
for i, cell in enumerate(original_cells): for i, cell in enumerate(original_cells):

View File

@ -172,11 +172,11 @@ backup_io = BackupIO()
def backup_io_iter(iterator): def backup_io_iter(iterator):
backup_io.op = 'read' backup_io.op = 'read'
while True: while True:
try: with backup_io:
with backup_io: try:
item = next(iterator) item = next(iterator)
except StopIteration: except StopIteration:
return return
yield item yield item

View File

@ -34,7 +34,7 @@ MAX_DATA_SIZE = 20971479
# MAX_OBJECT_SIZE = <20 MiB (MAX_DATA_SIZE) + 41 bytes for a Repository PUT header, which consists of # MAX_OBJECT_SIZE = <20 MiB (MAX_DATA_SIZE) + 41 bytes for a Repository PUT header, which consists of
# a 1 byte tag ID, 4 byte CRC, 4 byte size and 32 bytes for the ID. # a 1 byte tag ID, 4 byte CRC, 4 byte size and 32 bytes for the ID.
MAX_OBJECT_SIZE = MAX_DATA_SIZE + 41 # see LoggedIO.put_header_fmt.size assertion in repository module MAX_OBJECT_SIZE = MAX_DATA_SIZE + 41 # see LoggedIO.put_header_fmt.size assertion in repository module
assert MAX_OBJECT_SIZE == 20971520 == 20 * 1024 * 1024 assert MAX_OBJECT_SIZE == 20 * 1024 * 1024
# borg.remote read() buffer size # borg.remote read() buffer size
BUFSIZE = 10 * 1024 * 1024 BUFSIZE = 10 * 1024 * 1024

View File

@ -642,7 +642,8 @@ class Repository:
# get rid of the old, sparse, unused segments. free space. # get rid of the old, sparse, unused segments. free space.
for segment in unused: for segment in unused:
logger.debug('complete_xfer: deleting unused segment %d', segment) logger.debug('complete_xfer: deleting unused segment %d', segment)
assert self.segments.pop(segment) == 0, 'Corrupted segment reference count - corrupted index or hints' count = self.segments.pop(segment)
assert count == 0, 'Corrupted segment reference count - corrupted index or hints'
self.io.delete_segment(segment) self.io.delete_segment(segment)
del self.compact[segment] del self.compact[segment]
unused = [] unused = []