storage: fix UI crash when partition size gets capped
In cda6c54b87
, we introduced the accurate
size vs human readable size for the size form fields. Unfortunately, we
also introduced a regression when the size gets capped (when it exceeds
the maximum size defined on the form). Currently, specifying a size that
is beyond the maximum value fails when submitting the form with:
[...]
File "urwid/wimp.py", line 543, in keypress
self._emit('click')
File "urwid/widget.py", line 461, in _emit
signals.emit_signal(self, name, self, *args)
File "urwid/signals.py", line 265, in emit
result |= self._call_callback(callback, user_arg, user_args, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "urwid/signals.py", line 295, in _call_callback
return bool(callback(*args_to_pass))
^^^^^^^^^^^^^^^^^^^^^^^
File "subiquitycore/ui/form.py", line 486, in _click_done
emit_signal(self, "submit", self)
File "urwid/signals.py", line 265, in emit
result |= self._call_callback(callback, user_arg, user_args, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "urwid/signals.py", line 295, in _call_callback
return bool(callback(*args_to_pass))
^^^^^^^^^^^^^^^^^^^^^^^
File "subiquity/ui/views/filesystem/partition.py", line 636, in done
handler(self.disk, spec, partition=self.partition, gap=self.gap)
File "subiquity/common/filesystem/manipulator.py", line 334, in logical_volume_handler
lv.size = align_up(spec["size"])
^^^^^^^^^^^^^^^^^^^^^^
File "subiquity/models/filesystem.py", line 1382, in align_up
return (size + block_size - 1) & ~(block_size - 1)
~~~~~^~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'BoundFormField' and 'int'
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
d77bfbe1e0
commit
15f6848dc6
|
@ -117,8 +117,8 @@ class SizeWidget(StringEditor):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# This will invoke self.form.clean_size() and it is expected that
|
# This will invoke self.form.clean_size() and it is expected that
|
||||||
# size_str (and therefore self.value) are propertly aligned.
|
# size_str (and therefore self.value) are properly aligned.
|
||||||
self.accurate_value = self.form.size
|
self.accurate_value = self.form.size.value
|
||||||
else:
|
else:
|
||||||
aligned_sz = align_up(sz, self.form.alignment)
|
aligned_sz = align_up(sz, self.form.alignment)
|
||||||
aligned_sz_str = humanize_size(aligned_sz)
|
aligned_sz_str = humanize_size(aligned_sz)
|
||||||
|
|
Loading…
Reference in New Issue