@@ -23,9 +23,9 @@ use crate::{
23
23
24
24
use super :: super :: { Component , utils:: centered_rect_fixed} ;
25
25
26
- pub const GB_PER_NODE : usize = 35 ;
27
- pub const MB : usize = 1000 * 1000 ;
28
- pub const GB : usize = MB * 1000 ;
26
+ pub const GB_PER_NODE : u64 = 35 ;
27
+ pub const MB : u64 = 1000 * 1000 ;
28
+ pub const GB : u64 = MB * 1000 ;
29
29
pub const MAX_NODE_COUNT : usize = 50 ;
30
30
31
31
pub struct ManageNodes {
@@ -43,7 +43,7 @@ impl ManageNodes {
43
43
let nodes_to_start = std:: cmp:: min ( nodes_to_start, MAX_NODE_COUNT ) ;
44
44
let new = Self {
45
45
active : false ,
46
- available_disk_space_gb : get_available_space_b ( & storage_mountpoint) ? / GB ,
46
+ available_disk_space_gb : ( get_available_space_b ( & storage_mountpoint) ? / GB ) as usize ,
47
47
nodes_to_start_input : Input :: default ( ) . with_value ( nodes_to_start. to_string ( ) ) ,
48
48
old_value : Default :: default ( ) ,
49
49
storage_mountpoint : storage_mountpoint. clone ( ) ,
@@ -58,7 +58,10 @@ impl ManageNodes {
58
58
// Returns the max number of nodes to start
59
59
// It is the minimum of the available disk space and the max nodes limit
60
60
fn max_nodes_to_start ( & self ) -> usize {
61
- std:: cmp:: min ( self . available_disk_space_gb / GB_PER_NODE , MAX_NODE_COUNT )
61
+ std:: cmp:: min (
62
+ self . available_disk_space_gb / GB_PER_NODE as usize ,
63
+ MAX_NODE_COUNT ,
64
+ )
62
65
}
63
66
}
64
67
@@ -111,7 +114,7 @@ impl Component for ManageNodes {
111
114
. parse :: < usize > ( )
112
115
. unwrap_or ( 0 ) ;
113
116
// if it might exceed the available space or if more than max_node_count, then enter the max
114
- if new_value * GB_PER_NODE > self . available_disk_space_gb
117
+ if ( new_value as u64 ) * GB_PER_NODE > ( self . available_disk_space_gb as u64 ) * GB
115
118
|| new_value > MAX_NODE_COUNT
116
119
{
117
120
self . nodes_to_start_input = self
@@ -134,7 +137,9 @@ impl Component for ManageNodes {
134
137
if key. code == KeyCode :: Up {
135
138
if current_val + 1 >= MAX_NODE_COUNT {
136
139
MAX_NODE_COUNT
137
- } else if ( current_val + 1 ) * GB_PER_NODE <= self . available_disk_space_gb {
140
+ } else if ( ( current_val + 1 ) as u64 ) * GB_PER_NODE
141
+ <= ( self . available_disk_space_gb as u64 ) * GB
142
+ {
138
143
current_val + 1
139
144
} else {
140
145
current_val
@@ -179,7 +184,7 @@ impl Component for ManageNodes {
179
184
} ,
180
185
Action :: OptionsActions ( OptionsActions :: UpdateStorageDrive ( mountpoint, _drive_name) ) => {
181
186
self . storage_mountpoint . clone_from ( & mountpoint) ;
182
- self . available_disk_space_gb = get_available_space_b ( & mountpoint) ? / GB ;
187
+ self . available_disk_space_gb = ( get_available_space_b ( & mountpoint) ? / GB ) as usize ;
183
188
None
184
189
}
185
190
_ => None ,
@@ -266,7 +271,10 @@ impl Component for ManageNodes {
266
271
let info = Line :: from ( vec ! [
267
272
Span :: styled( "Using" , info_style) ,
268
273
Span :: styled(
269
- format!( " {}GB " , self . get_nodes_to_start_val( ) * GB_PER_NODE ) ,
274
+ format!(
275
+ " {}GB " ,
276
+ ( self . get_nodes_to_start_val( ) as u64 ) * GB_PER_NODE
277
+ ) ,
270
278
info_style. bold( ) ,
271
279
) ,
272
280
Span :: styled(
@@ -319,4 +327,4 @@ impl Component for ManageNodes {
319
327
320
328
Ok ( ( ) )
321
329
}
322
- }
330
+ }
0 commit comments