Disable selection of the btrfs backend when there are no btrfs

filesystems found.

The old check was for the presence of the 'btrfs' command, whose
package was a dependency of timeshift.
This commit is contained in:
Michael Webster 2022-07-04 12:58:22 -04:00
parent 829c78aa07
commit 96f9f8134a

View File

@ -97,37 +97,45 @@ class SnapshotBackendBox : Gtk.Box{
hbox.add (opt); hbox.add (opt);
opt_btrfs = opt; opt_btrfs = opt;
if (!check_for_btrfs_tools()) {
opt.sensitive = false;
opt_rsync.active = true;
}
opt_btrfs.toggled.connect(()=>{ opt_btrfs.toggled.connect(()=>{
if (opt_btrfs.active){ if (opt_btrfs.active){
if (check_for_btrfs_tools()){ App.btrfs_mode = true;
App.btrfs_mode = true; init_backend();
init_backend(); type_changed();
type_changed(); update_description();
update_description();
}
else{
opt_rsync.active = true;
}
} }
}); });
} }
private bool check_for_btrfs_tools(){ private bool check_for_btrfs_tools() {
try {
if (!cmd_exists("btrfs")){ const string args[] = {"lsblk", "-o", "FSTYPE", null};
var proc = new Subprocess.newv(
string msg = _("The 'btrfs' command is not available on your system. Install the 'btrfs-tools' package and try again."); args,
string title = _("BTRFS Tools Not Found"); SubprocessFlags.STDOUT_PIPE | SubprocessFlags.STDERR_SILENCE
gtk_set_busy(false, parent_window); );
gtk_messagebox(title, msg, parent_window, true);
Bytes stdout;
return false; if (proc.communicate(null, null, out stdout, null)) {
} string output = (string) Bytes.unref_to_data(stdout);
else{
return true; if (output.contains("btrfs")) {
} return true;
}
}
}
catch (Error e) {
log_error (e.message);
}
return false;
} }
private void add_description(){ private void add_description(){
Gtk.Expander expander = new Gtk.Expander(_("Help")); Gtk.Expander expander = new Gtk.Expander(_("Help"));