Merge "Fix crash with -l, -d /, and pseudo folders"

This commit is contained in:
Jenkins 2015-02-25 05:39:23 +00:00 committed by Gerrit Code Review
commit 731707f06d

@ -410,9 +410,8 @@ def st_list(parser, args, output_manager):
output_manager.print_msg( output_manager.print_msg(
item.get('name', item.get('subdir'))) item.get('name', item.get('subdir')))
else: else:
item_bytes = item.get('bytes')
total_bytes += item_bytes
if not container: # listing containers if not container: # listing containers
item_bytes = item.get('bytes')
byte_str = prt_bytes(item_bytes, options.human) byte_str = prt_bytes(item_bytes, options.human)
count = item.get('count') count = item.get('count')
total_count += count total_count += count
@ -431,19 +430,23 @@ def st_list(parser, args, output_manager):
else: # list container contents else: # list container contents
subdir = item.get('subdir') subdir = item.get('subdir')
if subdir is None: if subdir is None:
item_bytes = item.get('bytes')
byte_str = prt_bytes( byte_str = prt_bytes(
item_bytes, options.human) item_bytes, options.human)
date, xtime = item.get( date, xtime = item.get(
'last_modified').split('T') 'last_modified').split('T')
xtime = xtime.split('.')[0] xtime = xtime.split('.')[0]
else: else:
byte_str = prt_bytes(0, options.human) item_bytes = 0
byte_str = prt_bytes(
item_bytes, options.human)
date = xtime = '' date = xtime = ''
item_name = subdir item_name = subdir
if not options.totals: if not options.totals:
output_manager.print_msg( output_manager.print_msg(
"%s %10s %8s %s", byte_str, date, "%s %10s %8s %s", byte_str, date,
xtime, item_name) xtime, item_name)
total_bytes += item_bytes
# report totals # report totals
if options.long or options.human: if options.long or options.human: