[pve-devel] [PATCH installer] tui: persist disk selection for zfs and btrfs

Stefan Sterz s.sterz at proxmox.com
Tue Jun 27 15:59:58 CEST 2023


On 27.06.23 15:57, Lukas Wagner wrote:
> 
> 
> On 6/27/23 15:34, Maximiliano Sandoval wrote:
>>>     impl BtrfsBootdiskOptions {
>>> -    pub fn defaults_from(disk: &Disk) -> Self {
>>> +    pub fn defaults_from(disks: &[Disk]) -> Self {
>>> +        let disk = &disks[0];
>>>           Self {
>>>               disk_size: disk.size,
>>> +            selected_disks: (0..disks.len()).collect(),
>>
>> Any reason not to use Vec::with_capacity(disks.len()) here?
>>
> 
> I haven't really examined the rest of the code, but wouldn't that change
> the behavior
> completely? E.g., if `disk.len()` is 3, then
> `(0..disks.len()).collect()` will give you a Vec [0, 1, 2], while
> `Vec::with_capacity(disks.len())` would give you an empty Vec with an
> initial capacity
> of at least 3.
> 
> 

yes. we've already discussed this off list. this is needed here because
otherwise you panic out in `MultiDiskOptionsView::new()` because
`selected_disk` would have a length of zero. the ascending numbers are
needed to have the same initial selection as we currently do.

i'll send a patch with the other nits resolved in a minute.





More information about the pve-devel mailing list