1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
Index: diskdrake/interactive.pm
===================================================================
--- diskdrake/interactive.pm (revision 6434)
+++ diskdrake/interactive.pm (working copy)
@@ -323,7 +323,10 @@
sub hd_possible_actions_extra {
my ($_hd) = @_;
- $::expert ? N_("Toggle to normal mode") : N_("Toggle to expert mode");
+ (
+ N_("Refresh"),
+ $::expert ? N_("Toggle to normal mode") : N_("Toggle to expert mode"),
+ );
}
@@ -338,6 +341,29 @@
&hd_possible_actions, N_("Hard disk drive information");
}
+sub Refresh {
+ my ($in, $current_hd, $all_hds) = @_;
+
+ # redo the first2 steps in a diff variable
+ my $all_hds2 = fsedit::get_hds({}, $in);
+ # TODO: do i need to get_raw_hds too? are raw disks shown?
+ # fs::get_raw_hds('', $all_hds2);
+
+ # file based index of old hds
+ my %old_hds = map { $_->{file} => $_ } @{$all_hds->{hds}};
+
+ # same for new, but also push the new hd to all_hds if it has different size or not exist
+ my %new_hds = map { push @{$all_hds->{hds}} if (!defined $old_hds{$_->{file}} || $_->{total_sectors} != $old_hds{$_->{file}}->{total_sectors}); $_->{file} => $_ } @{$all_hds2->{hds}};
+
+ # find deleted ones
+ for my $hd (@{$all_hds->{hds}}) {
+ if (!defined $new_hds{$hd->{file}}) {
+ # TODO: mark the hd as unavailable
+ }
+ }
+ $all_hds;
+}
+
sub Clear_all {
my ($in, $hd, $all_hds) = @_;
return if detect_devices::is_xbox(); #- do not let them wipe the OS
@@ -1134,6 +1160,7 @@
*{'Toggle to normal mode'} = sub() { $::expert = 0 };
*{'Toggle to expert mode'} = sub() { $::expert = 1 };
*{'Clear all'} = \&Clear_all;
+ *{'Refresh'} = \&Refresh;
*{'Auto allocate'} = \&Auto_allocate;
*{'Mount point'} = \&Mount_point;
*{'Modify RAID'} = \&ModifyRAID;
|